1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-25 11:37:56 +00:00

Make sure to ignore the leading NULL byte from Linux abstract namespace.

This commit is contained in:
Jung-uk Kim 2011-10-06 21:09:28 +00:00
parent f05531a392
commit c02637c717
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=226073

View File

@ -90,6 +90,7 @@ linux_getsockaddr(struct sockaddr **sap, const struct osockaddr *osa, int osalen
int oldv6size;
struct sockaddr_in6 *sin6;
#endif
char *name;
int alloclen, hdrlen, namelen;
if (osalen < 2 || osalen > UCHAR_MAX || !osa)
@ -158,8 +159,15 @@ linux_getsockaddr(struct sockaddr **sap, const struct osockaddr *osa, int osalen
if (bdom == AF_LOCAL && osalen > sizeof(struct sockaddr_un)) {
hdrlen = offsetof(struct sockaddr_un, sun_path);
namelen = strnlen(((struct sockaddr_un *)kosa)->sun_path,
osalen - hdrlen);
name = ((struct sockaddr_un *)kosa)->sun_path;
if (*name == '\0') {
/*
* Linux abstract namespace starts with a NULL byte.
* XXX We do not support abstract namespace yet.
*/
namelen = strnlen(name + 1, osalen - hdrlen - 1) + 1;
} else
namelen = strnlen(name, osalen - hdrlen);
if (hdrlen + namelen > sizeof(struct sockaddr_un)) {
error = ENAMETOOLONG;
goto out;