1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-26 14:04:03 +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]);
}
bufpos = snprintf(buf, sizeof(buf)-1, "%s@%s", action, devpath);
bufpos = snprintf(buf, sizeof(buf), "%s@%s", action, devpath);
bufpos++;
for (i = 0; environ[i] != NULL && bufpos < (sizeof(buf)-1); i++) {
bufpos += strlcpy(&buf[bufpos], environ[i], sizeof(buf) - bufpos-1);
for (i = 0; environ[i] != NULL && bufpos < (sizeof(buf)); i++) {
bufpos += strlcpy(&buf[bufpos], environ[i], sizeof(buf) - bufpos);
bufpos++;
}
if (bufpos > sizeof(buf))