mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
nsswitch: fix double free errors in nsstest.c
We need to zero out static pointers on free. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13283 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
parent
7b86b94c71
commit
da784305e7
@ -21,6 +21,8 @@
|
||||
#include "replace.h"
|
||||
#include "nsswitch/nsstest.h"
|
||||
|
||||
#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
|
||||
|
||||
static const char *so_path = "/lib/libnss_winbind.so";
|
||||
static const char *nss_name = "winbind";
|
||||
static int nss_errno;
|
||||
@ -48,10 +50,10 @@ static void *find_fn(const char *name)
|
||||
if (!res) {
|
||||
printf("Can't find function %s\n", s);
|
||||
total_errors++;
|
||||
free(s);
|
||||
SAFE_FREE(s);
|
||||
return NULL;
|
||||
}
|
||||
free(s);
|
||||
SAFE_FREE(s);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -194,12 +196,12 @@ again:
|
||||
goto again;
|
||||
}
|
||||
if (status == NSS_STATUS_NOTFOUND) {
|
||||
free(buf);
|
||||
SAFE_FREE(buf);
|
||||
return NULL;
|
||||
}
|
||||
if (status != NSS_STATUS_SUCCESS) {
|
||||
report_nss_error("getgrent", status);
|
||||
free(buf);
|
||||
SAFE_FREE(buf);
|
||||
return NULL;
|
||||
}
|
||||
return &grp;
|
||||
@ -232,12 +234,12 @@ again:
|
||||
goto again;
|
||||
}
|
||||
if (status == NSS_STATUS_NOTFOUND) {
|
||||
free(buf);
|
||||
SAFE_FREE(buf);
|
||||
return NULL;
|
||||
}
|
||||
if (status != NSS_STATUS_SUCCESS) {
|
||||
report_nss_error("getgrnam", status);
|
||||
free(buf);
|
||||
SAFE_FREE(buf);
|
||||
return NULL;
|
||||
}
|
||||
return &grp;
|
||||
@ -271,12 +273,12 @@ again:
|
||||
goto again;
|
||||
}
|
||||
if (status == NSS_STATUS_NOTFOUND) {
|
||||
free(buf);
|
||||
SAFE_FREE(buf);
|
||||
return NULL;
|
||||
}
|
||||
if (status != NSS_STATUS_SUCCESS) {
|
||||
report_nss_error("getgrgid", status);
|
||||
free(buf);
|
||||
SAFE_FREE(buf);
|
||||
return NULL;
|
||||
}
|
||||
return &grp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user