sd-bus: make parsing of AF_UNIX socket addresses more strict
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.
This commit is contained in:
@@ -730,7 +730,7 @@ static int parse_unix_address(sd_bus *b, const char **p, char **guid) {
|
||||
|
||||
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;
|
||||
@@ -738,7 +738,7 @@ static int parse_unix_address(sd_bus *b, const char **p, char **guid) {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user