forked from wrenn/wrenn
Fix concurrency, security, and correctness issues across backend and frontend
- C1: Add sync.RWMutex to vm.Manager to protect concurrent vms map access - H1: Fix IP arithmetic overflow in network slot addressing (byte truncation) - H5: Fix MultiplexedChannel.Fork() TOCTOU race (move exited check inside lock) - H8: Remove snapshot overwrite — return template_name_taken conflict instead - H9: Wrap DeleteAccount DB ops in a transaction, make team deletion fatal - H10: Sanitize serviceErrToHTTP to stop leaking internal error messages - H11: Add deleted_at IS NULL to GetUserByEmail/GetUserByID queries - H12: Add id DESC to audit log composite index for cursor pagination - H15: Delete dead AuthModal.svelte component - H17: Move JWT from WebSocket URL query param to first WS message - H18: Fix $derived to $derived.by in FilesTab breadcrumbs
This commit is contained in:
@ -131,26 +131,31 @@ type Slot struct {
|
||||
}
|
||||
|
||||
// NewSlot computes the addressing for the given slot index (1-based).
|
||||
// Index must be in [1, 32767] so that veth offset (index*2) fits in 16 bits.
|
||||
func NewSlot(index int) *Slot {
|
||||
if index < 1 || index > 32767 {
|
||||
panic(fmt.Sprintf("slot index %d out of range [1, 32767]", index))
|
||||
}
|
||||
|
||||
hostBaseIP := net.ParseIP(hostBase).To4()
|
||||
vrtBaseIP := net.ParseIP(vrtBase).To4()
|
||||
|
||||
hostIP := make(net.IP, 4)
|
||||
copy(hostIP, hostBaseIP)
|
||||
hostIP[2] += byte(index >> 8)
|
||||
hostIP[3] += byte(index & 0xFF)
|
||||
hostIP[2] = hostBaseIP[2] + byte(index>>8)
|
||||
hostIP[3] = hostBaseIP[3] + byte(index&0xFF)
|
||||
|
||||
vethOffset := index * vrtAddressesPerSlot
|
||||
vethIP := make(net.IP, 4)
|
||||
copy(vethIP, vrtBaseIP)
|
||||
vethIP[2] += byte(vethOffset >> 8)
|
||||
vethIP[3] += byte(vethOffset & 0xFF)
|
||||
vethIP[2] = vrtBaseIP[2] + byte(vethOffset>>8)
|
||||
vethIP[3] = vrtBaseIP[3] + byte(vethOffset&0xFF)
|
||||
|
||||
vpeerOffset := vethOffset + 1
|
||||
vpeerIP := make(net.IP, 4)
|
||||
copy(vpeerIP, vrtBaseIP)
|
||||
vpeerIP[2] += byte(vpeerOffset >> 8)
|
||||
vpeerIP[3] += byte(vpeerOffset & 0xFF)
|
||||
vpeerIP[2] = vrtBaseIP[2] + byte(vpeerOffset>>8)
|
||||
vpeerIP[3] = vrtBaseIP[3] + byte(vpeerOffset&0xFF)
|
||||
|
||||
return &Slot{
|
||||
Index: index,
|
||||
|
||||
Reference in New Issue
Block a user