summaryrefslogtreecommitdiff
path: root/udev_rules.c
diff options
context:
space:
mode:
authorMichael Morony <michael.morony@gmail.com>2007-08-24 08:14:21 +0200
committerKay Sievers <kay.sievers@vrfy.org>2007-08-24 08:14:21 +0200
commit1f7a36f2c0953c60a8d7acadc281285a0b84fb46 (patch)
treeb36910854ba772c399da4ef6624443b5eba0b9fc /udev_rules.c
parent7e599863919a62b0a072b5ca7a0037527d54d335 (diff)
set buffer size if strlcpy/strlcat indicate truncation
Diffstat (limited to 'udev_rules.c')
-rw-r--r--udev_rules.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/udev_rules.c b/udev_rules.c
index 0dcbf156ea..35db958c8d 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)