fix possible segfault in sigar_group_name_get
This commit is contained in:
parent
7ec8647d64
commit
d6cb75e1d2
|
@ -1,3 +1,7 @@
|
||||||
|
2004-11-29 Doug MacEachern <dougm@hyperic.net>
|
||||||
|
|
||||||
|
* fix possible segfault in sigar_group_name_get if gid == -1
|
||||||
|
|
||||||
2004-11-22 Doug MacEachern <dougm@hyperic.net>
|
2004-11-22 Doug MacEachern <dougm@hyperic.net>
|
||||||
|
|
||||||
* fix bug in RegistryKey.openSubKey under WebSphere 4.0 jdk
|
* fix bug in RegistryKey.openSubKey under WebSphere 4.0 jdk
|
||||||
|
|
12
src/sigar.c
12
src/sigar.c
|
@ -263,7 +263,17 @@ int sigar_group_name_get(sigar_t *sigar, int gid, char *buf, int buflen)
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
strncpy(buf, gr->gr_name, buflen);
|
if (gr && gr->gr_name) {
|
||||||
|
strncpy(buf, gr->gr_name, buflen);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* seen on linux.. apache httpd.conf has:
|
||||||
|
* Group #-1
|
||||||
|
* results in uid == -1 and gr == NULL.
|
||||||
|
* wtf getgrgid_r doesnt fail instead?
|
||||||
|
*/
|
||||||
|
sprintf(buf, "%d", gid);
|
||||||
|
}
|
||||||
buf[buflen-1] = '\0';
|
buf[buflen-1] = '\0';
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
|
|
Loading…
Reference in New Issue