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>
This commit is contained in:
parent
a5cd79fec4
commit
2b710bac54
3
policy.c
3
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);
|
||||
|
|
Loading…
Reference in New Issue