X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Frunas.c;h=6f882041d5a4789939a67ad5c245b7e9e2be3563;hb=c043a8d8da78bed7e11ad7e578466b83a42d3695;hp=cfc898f166d45e8f313b2e060c1518568d54fcce;hpb=a62bbe8cacc7014175da33f64f917533fea7810d;p=lttng-tools.git diff --git a/src/common/runas.c b/src/common/runas.c index cfc898f16..6f882041d 100644 --- a/src/common/runas.c +++ b/src/common/runas.c @@ -830,14 +830,15 @@ static int get_user_infos_from_uid( { int ret; char *buf = NULL; - size_t buf_size; + long raw_get_pw_buf_size; + size_t get_pw_buf_size; struct passwd pwd; struct passwd *result = NULL; /* Fetch the max size for the temporary buffer. */ errno = 0; - buf_size = sysconf(_SC_GETPW_R_SIZE_MAX); - if (buf_size < 0) { + raw_get_pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX); + if (raw_get_pw_buf_size < 0) { if (errno != 0) { PERROR("Failed to query _SC_GETPW_R_SIZE_MAX"); goto error; @@ -846,16 +847,18 @@ static int get_user_infos_from_uid( /* Limit is indeterminate. */ WARN("Failed to query _SC_GETPW_R_SIZE_MAX as it is " "indeterminate; falling back to default buffer size"); - buf_size = GETPW_BUFFER_FALLBACK_SIZE; + raw_get_pw_buf_size = GETPW_BUFFER_FALLBACK_SIZE; } - buf = zmalloc(buf_size); + get_pw_buf_size = (size_t) raw_get_pw_buf_size; + + buf = zmalloc(get_pw_buf_size); if (buf == NULL) { PERROR("Failed to allocate buffer to get password file entries"); goto error; } - ret = getpwuid_r(uid, &pwd, buf, buf_size, &result); + ret = getpwuid_r(uid, &pwd, buf, get_pw_buf_size, &result); if (ret < 0) { PERROR("Failed to get user information for user: uid = %d", (int) uid);