X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_rules.c;h=35db958c8df4959fbb68664b1aed7afb0124a3aa;hp=0dcbf156ea14d9708b4b53b5d9cd60b4b956e0ff;hb=79ef8431c952349d9f31c899adb579c3ff83a80b;hpb=03f65fe6a9cd32a5861b1a929cdf4f7eddbd593f diff --git a/udev_rules.c b/udev_rules.c index 0dcbf156e..35db958c8 100644 --- a/udev_rules.c +++ b/udev_rules.c @@ -475,10 +475,12 @@ static int pass_env_to_socket(const char *sockname, const char *devpath, const c bufpos = snprintf(buf, sizeof(buf)-1, "%s@%s", action, devpath); bufpos++; - for (i = 0; environ[i] != NULL && bufpos < sizeof(buf); i++) { + for (i = 0; environ[i] != NULL && bufpos < (sizeof(buf)-1); i++) { bufpos += strlcpy(&buf[bufpos], environ[i], sizeof(buf) - bufpos-1); bufpos++; } + if (bufpos > sizeof(buf)) + bufpos = sizeof(buf); count = sendto(sock, &buf, bufpos, 0, (struct sockaddr *)&saddr, addrlen); if (count < 0)