mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
util.c (virGetUserEnt): don't use a negative value as allocation size
* src/util/util.c (virGetUserEnt): In the unlikely event that sysconf(_SC_GETPW_R_SIZE_MAX) fails, don't use -1 as the size in the subsequent allocation.
This commit is contained in:
parent
3bd3d6b0bf
commit
5ec55b4ff0
@ -2317,7 +2317,13 @@ static char *virGetUserEnt(virConnectPtr conn,
|
||||
char *ret;
|
||||
struct passwd pwbuf;
|
||||
struct passwd *pw = NULL;
|
||||
size_t strbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||
long val = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||
size_t strbuflen = val;
|
||||
|
||||
if (val < 0) {
|
||||
virReportSystemError(conn, errno, "%s", _("sysconf failed"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (VIR_ALLOC_N(strbuf, strbuflen) < 0) {
|
||||
virReportOOMError(conn);
|
||||
|
Loading…
x
Reference in New Issue
Block a user