From 1f7a36f2c0953c60a8d7acadc281285a0b84fb46 Mon Sep 17 00:00:00 2001 From: Michael Morony Date: Fri, 24 Aug 2007 08:14:21 +0200 Subject: set buffer size if strlcpy/strlcat indicate truncation --- udev_rules.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'udev_rules.c') 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) -- cgit v1.2.3-54-g00ecf