This is something of an off-by-one error.  On Linux, the path doesn't have to be zero-terminated if it's sizeof(s.sun_path) bytes long while on (most of?) the BSDs it's possible to use a path that's longer than that by passing sizeof(struct sockaddr_un) + extra_bytes as the addrlen argument.

(On that subject, I found a nice little local exploit when checking if that works on XNU: https://gist.github.com/bnoordhuis/8882643)