1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-04 21:47:31 +03:00

fix off-by-one in pass_env_to_socket()

This commit is contained in:
Alan Jenkins 2008-09-09 00:48:17 +02:00 committed by Kay Sievers
parent ab7ab02556
commit 9d7e1b3fdd

View File

@ -486,10 +486,10 @@ static int pass_env_to_socket(struct udev *udev, const char *sockpath, const cha
saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]); saddrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]);
} }
bufpos = snprintf(buf, sizeof(buf)-1, "%s@%s", action, devpath); bufpos = snprintf(buf, sizeof(buf), "%s@%s", action, devpath);
bufpos++; bufpos++;
for (i = 0; environ[i] != NULL && bufpos < (sizeof(buf)-1); i++) { for (i = 0; environ[i] != NULL && bufpos < (sizeof(buf)); i++) {
bufpos += strlcpy(&buf[bufpos], environ[i], sizeof(buf) - bufpos-1); bufpos += strlcpy(&buf[bufpos], environ[i], sizeof(buf) - bufpos);
bufpos++; bufpos++;
} }
if (bufpos > sizeof(buf)) if (bufpos > sizeof(buf))