0092-pmap: Harden one_proc().
Replace sprintf() with snprintf(). Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
parent
550a2a21f9
commit
991b41cb32
4
pmap.c
4
pmap.c
@ -545,11 +545,11 @@ static int one_proc (struct pids_stack *p)
|
|||||||
printf("%u: %s\n", PIDS_VAL(tgid, s_int, p, Pids_info), PIDS_VAL(cmdline, str, p, Pids_info));
|
printf("%u: %s\n", PIDS_VAL(tgid, s_int, p, Pids_info), PIDS_VAL(cmdline, str, p, Pids_info));
|
||||||
|
|
||||||
if (x_option || X_option || c_option) {
|
if (x_option || X_option || c_option) {
|
||||||
sprintf(buf, "/proc/%u/smaps", PIDS_VAL(tgid, s_int, p, Pids_info));
|
snprintf(buf, sizeof buf, "/proc/%u/smaps", PIDS_VAL(tgid, s_int, p, Pids_info));
|
||||||
if ((fp = fopen(buf, "r")) == NULL)
|
if ((fp = fopen(buf, "r")) == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf, "/proc/%u/maps", PIDS_VAL(tgid, s_int, p, Pids_info));
|
snprintf(buf, sizeof buf, "/proc/%u/maps", PIDS_VAL(tgid, s_int, p, Pids_info));
|
||||||
if ((fp = fopen(buf, "r")) == NULL)
|
if ((fp = fopen(buf, "r")) == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user