mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
lib: Fix CID 1596761 Resource leak
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
parent
30b0fa892a
commit
f3e7d450ea
@ -89,15 +89,17 @@ static char *get_user_home_dir(TALLOC_CTX *mem_ctx)
|
|||||||
rc = getpwuid_r(getuid(), &pwd, buf, len, &pwdbuf);
|
rc = getpwuid_r(getuid(), &pwd, buf, len, &pwdbuf);
|
||||||
while (rc == ERANGE) {
|
while (rc == ERANGE) {
|
||||||
size_t newlen = 2 * len;
|
size_t newlen = 2 * len;
|
||||||
|
char *tmp = NULL;
|
||||||
if (newlen < len) {
|
if (newlen < len) {
|
||||||
/* Overflow */
|
/* Overflow */
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
len = newlen;
|
len = newlen;
|
||||||
buf = talloc_realloc_size(mem_ctx, buf, len);
|
tmp = talloc_realloc_size(mem_ctx, buf, len);
|
||||||
if (buf == NULL) {
|
if (tmp == NULL) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
buf = tmp;
|
||||||
rc = getpwuid_r(getuid(), &pwd, buf, len, &pwdbuf);
|
rc = getpwuid_r(getuid(), &pwd, buf, len, &pwdbuf);
|
||||||
}
|
}
|
||||||
if (rc != 0 || pwdbuf == NULL ) {
|
if (rc != 0 || pwdbuf == NULL ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user