this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

FIx crash with Unix socket in `bind`

The comment pretty much explains it: we need to make sure we have enough space for the vchroot path fixup. This was causing segfaults when trying to use Unix sockets sometimes (consistently reproducible with the Mio test suite's Unix socket tests).

+5 -1
+5 -1
src/kernel/emulation/linux/network/bind.c
··· 3 3 #include "../errno.h" 4 4 #include <linux-syscalls/linux.h> 5 5 #include <sys/errno.h> 6 + #include <sys/socket.h> 6 7 #include "duct.h" 7 8 8 9 extern void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n); ··· 18 19 if (socklen > 512) 19 20 return -EINVAL; 20 21 21 - fixed = __builtin_alloca(socklen); 22 + // if we're going to be fixing up the path for vchroot, 23 + // we need to make sure we allocate the full structure so we have max path length 24 + fixed = __builtin_alloca((((struct sockaddr_fixup*)name)->bsd_family == PF_LOCAL) ? sizeof(struct sockaddr_fixup) : socklen); 22 25 memcpy(fixed, name, socklen); 23 26 24 27 fixed->linux_family = sfamily_bsd_to_linux(fixed->bsd_family); ··· 37 40 38 41 strncpy(fixed->sun_path, vc.path, sizeof(fixed->sun_path) - 1); 39 42 fixed->sun_path[sizeof(fixed->sun_path) - 1] = '\0'; 43 + socklen = sizeof(*fixed) - sizeof(fixed->sun_path) + strlen(fixed->sun_path); 40 44 } 41 45 42 46 #ifdef __NR_socketcall