summaryrefslogtreecommitdiff
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
parent7e599863919a62b0a072b5ca7a0037527d54d335 (diff)
set buffer size if strlcpy/strlcat indicate truncation
-rw-r--r--udev_rules.c4
-rw-r--r--udev_sysfs.c2
-rw-r--r--udevinfo.c2
-rw-r--r--udevmonitor.c4
-rw-r--r--udevtrigger.c2
5 files changed, 9 insertions, 5 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)
diff --git a/udev_sysfs.c b/udev_sysfs.c
index 34ae9ac14f..d5b04c310f 100644
--- a/udev_sysfs.c
+++ b/udev_sysfs.c
@@ -355,6 +355,8 @@ char *sysfs_attr_get_value(const char *devpath, const char *attr_name)
dbg("open '%s'/'%s'", devpath, attr_name);
sysfs_len = strlcpy(path_full, sysfs_path, sizeof(path_full));
+ if(sysfs_len >= sizeof(path_full))
+ sysfs_len = sizeof(path_full) - 1;
path = &path_full[sysfs_len];
strlcat(path_full, devpath, sizeof(path_full));
strlcat(path_full, "/", sizeof(path_full));
diff --git a/udevinfo.c b/udevinfo.c
index d0b1c447f4..be9aa769e1 100644
--- a/udevinfo.c
+++ b/udevinfo.c
@@ -79,6 +79,8 @@ static void print_all_attributes(const char *devpath, const char *key)
if (attr_value == NULL)
continue;
len = strlcpy(value, attr_value, sizeof(value));
+ if(len >= sizeof(value))
+ len = sizeof(value) - 1;
dbg("attr '%s'='%s'(%zi)", dent->d_name, value, len);
/* remove trailing newlines */
diff --git a/udevmonitor.c b/udevmonitor.c
index a9cc0614ff..644a955090 100644
--- a/udevmonitor.c
+++ b/udevmonitor.c
@@ -43,7 +43,6 @@ static int init_udev_monitor_socket(void)
{
struct sockaddr_un saddr;
socklen_t addrlen;
- const int feature_on = 1;
int retval;
memset(&saddr, 0x00, sizeof(saddr));
@@ -67,9 +66,6 @@ static int init_udev_monitor_socket(void)
return -1;
}
- /* enable receiving of the sender credentials */
- setsockopt(udev_monitor_sock, SOL_SOCKET, SO_PASSCRED, &feature_on, sizeof(feature_on));
-
return 0;
}
diff --git a/udevtrigger.c b/udevtrigger.c
index cf8f209b1c..309c54ab68 100644
--- a/udevtrigger.c
+++ b/udevtrigger.c
@@ -435,6 +435,8 @@ static void scan_failed(void)
continue;
start = strlcpy(device, sysfs_path, sizeof(device));
+ if(start >= sizeof(device))
+ start = sizeof(device) - 1;
strlcat(device, dent->d_name, sizeof(device));
path_decode(&device[start]);
device_list_insert(device);