socket-util: change sockaddr_un_set_path() to return recognizable error on 108ch limit
This way we can implement nice fallbacks later on. While we are at it, provide a test for this (one that is a bit over the top, but then again, we can never have enough tests).
This commit is contained in:
committed by
Yu Watanabe
parent
7eeedcfcb1
commit
dfa2b389a6
@@ -1236,7 +1236,10 @@ int sockaddr_un_set_path(struct sockaddr_un *ret, const char *path) {
|
||||
* addresses!), which the kernel doesn't. We do this to reduce chance of incompatibility with other apps that
|
||||
* do not expect non-NUL terminated file system path. */
|
||||
if (l+1 > sizeof(ret->sun_path))
|
||||
return -EINVAL;
|
||||
return path[0] == '@' ? -EINVAL : -ENAMETOOLONG; /* return a recognizable error if this is
|
||||
* too long to fit into a sockaddr_un, but
|
||||
* is a file system path, and thus might be
|
||||
* connectible via O_PATH indirection. */
|
||||
|
||||
*ret = (struct sockaddr_un) {
|
||||
.sun_family = AF_UNIX,
|
||||
|
||||
Reference in New Issue
Block a user