Insist on NUL termination, just to be safe rather than sorry. The kernel
doesn't require it, but it's really annoying if people rely on this,
hence refuse this early.
if (path) {
l = strlen(path);
- if (l > sizeof(b->sockaddr.un.sun_path))
+ if (l >= sizeof(b->sockaddr.un.sun_path)) /* We insist on NUL termination */
return -E2BIG;
b->sockaddr.un.sun_family = AF_UNIX;
b->sockaddr_size = offsetof(struct sockaddr_un, sun_path) + l;
} else if (abstract) {
l = strlen(abstract);
- if (l > sizeof(b->sockaddr.un.sun_path) - 1)
+ if (l >= sizeof(b->sockaddr.un.sun_path) - 1) /* We insist on NUL termination */
return -E2BIG;
b->sockaddr.un.sun_family = AF_UNIX;