sanity check strchr results
This commit is contained in:
parent
b4a3efc065
commit
efb74c1703
|
@ -757,9 +757,12 @@ static int proc_stat_read(sigar_t *sigar, sigar_pid_t pid)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = strchr(ptr, '(')+1;
|
if (!(ptr = strchr(ptr, '('))) {
|
||||||
|
return EINVAL;
|
||||||
tmp = strrchr(ptr, ')');
|
}
|
||||||
|
if (!(tmp = strrchr(++ptr, ')'))) {
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
len = tmp-ptr;
|
len = tmp-ptr;
|
||||||
|
|
||||||
if (len >= sizeof(pstat->name)) {
|
if (len >= sizeof(pstat->name)) {
|
||||||
|
|
Loading…
Reference in New Issue