1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +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:
Volker Lendecke 2024-09-29 09:58:13 +02:00
parent 30b0fa892a
commit f3e7d450ea

View File

@ -89,15 +89,17 @@ static char *get_user_home_dir(TALLOC_CTX *mem_ctx)
rc = getpwuid_r(getuid(), &pwd, buf, len, &pwdbuf);
while (rc == ERANGE) {
size_t newlen = 2 * len;
char *tmp = NULL;
if (newlen < len) {
/* Overflow */
goto done;
}
len = newlen;
buf = talloc_realloc_size(mem_ctx, buf, len);
if (buf == NULL) {
tmp = talloc_realloc_size(mem_ctx, buf, len);
if (tmp == NULL) {
goto done;
}
buf = tmp;
rc = getpwuid_r(getuid(), &pwd, buf, len, &pwdbuf);
}
if (rc != 0 || pwdbuf == NULL ) {