summaryrefslogtreecommitdiffstats
path: root/policy.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2011-11-01 04:56:12 +0100
committerNeilBrown <neilb@suse.de>2011-11-01 04:56:12 +0100
commit2b710bac540f07489246a1d53b665f74a9c7dd50 (patch)
tree6cfb720c72d7aefc35be9982eecbe0a06f6e404f /policy.c
parentpolicy_add(): Add missing va_end() (diff)
downloadmdadm-2b710bac540f07489246a1d53b665f74a9c7dd50.tar.xz
mdadm-2b710bac540f07489246a1d53b665f74a9c7dd50.zip
Write_rules(): Avoid stack corruption if using extremely long udev pathname
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'policy.c')
-rw-r--r--policy.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/policy.c b/policy.c
index 11142868..cd260c69 100644
--- a/policy.c
+++ b/policy.c
@@ -883,7 +883,8 @@ int Write_rules(char *rule_name)
char udev_rule_file[PATH_MAX];
if (rule_name) {
- strcpy(udev_rule_file, rule_name);
+ strncpy(udev_rule_file, rule_name, sizeof(udev_rule_file) - 6);
+ udev_rule_file[sizeof(udev_rule_file) - 6] = '\0';
strcat(udev_rule_file, ".temp");
fd = creat(udev_rule_file,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);