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=e2877abe70be961b112c84beac4390b64985815a;hb=79ef8431c952349d9f31c899adb579c3ff83a80b;hpb=19096c087f8e1fc9f60ceb948f8be9b179885569 diff --git a/udev_rules.c b/udev_rules.c index e2877abe7..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) @@ -1003,6 +1005,14 @@ static int match_rule(struct udevice *udev, struct udev_rule *rule) strlcat(filename, "/", sizeof(filename)); strlcat(filename, attr, sizeof(filename)); } + } else if (filename[0] != '/') { + char tmp[PATH_SIZE]; + + strlcpy(tmp, sysfs_path, sizeof(tmp)); + strlcat(tmp, udev->dev->devpath, sizeof(tmp)); + strlcat(tmp, "/", sizeof(tmp)); + strlcat(tmp, filename, sizeof(tmp)); + strlcpy(filename, tmp, sizeof(filename)); } match = (stat(filename, &statbuf) == 0);