Minor simplification in sockaddr_un_set_path()

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-09-09 23:57:59 +02:00
parent 08224f38ac
commit c097bf1f50
1 changed files with 1 additions and 3 deletions

View File

@ -1118,12 +1118,10 @@ int sockaddr_un_set_path(struct sockaddr_un *ret, const char *path) {
* reference paths in the abstract namespace that include NUL bytes in the name. */
l = strlen(path);
if (l == 0)
if (l < 2)
return -EINVAL;
if (!IN_SET(path[0], '/', '@'))
return -EINVAL;
if (path[1] == 0)
return -EINVAL;
/* Don't allow paths larger than the space in sockaddr_un. Note that we are a tiny bit more restrictive than
* the kernel is: we insist on NUL termination (both for abstract namespace and regular file system socket