diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-05-10 16:15:26 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-05-13 14:47:58 +0200 |
commit | dfa2b389a627652e0e190473817073c44cf19f2b (patch) | |
tree | 2fb6018667bfb3044997727a6904f63711615780 /src/basic | |
parent | Merge pull request #23337 from yuwata/sd-device-new-from-subsystem-sysname (diff) | |
download | systemd-dfa2b389a627652e0e190473817073c44cf19f2b.tar.xz systemd-dfa2b389a627652e0e190473817073c44cf19f2b.zip |
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).
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/socket-util.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 8d0494ece5..0dfe2a7dbc 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -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, |