sanity check strchr results

This commit is contained in:
Doug MacEachern 2008-01-29 00:08:29 +00:00
parent b4a3efc065
commit efb74c1703
1 changed files with 6 additions and 3 deletions

View File

@ -757,9 +757,12 @@ static int proc_stat_read(sigar_t *sigar, sigar_pid_t pid)
return status;
}
ptr = strchr(ptr, '(')+1;
tmp = strrchr(ptr, ')');
if (!(ptr = strchr(ptr, '('))) {
return EINVAL;
}
if (!(tmp = strrchr(++ptr, ')'))) {
return EINVAL;
}
len = tmp-ptr;
if (len >= sizeof(pstat->name)) {