diff options
author | Herb Lewis <herb@samba.org> | 2001-12-21 17:46:53 +0000 |
---|---|---|
committer | Herb Lewis <herb@samba.org> | 2001-12-21 17:46:53 +0000 |
commit | 7e0d6938b9ca1b64c321d300c577dac8aa0b548c (patch) | |
tree | 8827b576de7d7106714c63d7cf9e065aeff1ebc4 | |
parent | 850fb4b5b49d39a52b1c0d58f79f796369c9ab37 (diff) | |
download | samba-7e0d6938b9ca1b64c321d300c577dac8aa0b548c.tar.gz samba-7e0d6938b9ca1b64c321d300c577dac8aa0b548c.tar.xz samba-7e0d6938b9ca1b64c321d300c577dac8aa0b548c.zip |
fix memory leak
-rw-r--r-- | source/nsswitch/wb_common.c | 21 | ||||
-rw-r--r-- | source/nsswitch/winbind_nss.c | 17 |
2 files changed, 22 insertions, 16 deletions
diff --git a/source/nsswitch/wb_common.c b/source/nsswitch/wb_common.c index 082f3cae8f7..d3feaeb4504 100644 --- a/source/nsswitch/wb_common.c +++ b/source/nsswitch/wb_common.c @@ -31,6 +31,16 @@ int winbindd_fd = -1; /* fd for winbindd socket */ static char *excluded_domain; +/* Free a response structure */ + +void free_response(struct winbindd_response *response) +{ + /* Free any allocated extra_data */ + + if (response) + SAFE_FREE(response->extra_data); +} + /* smbd needs to be able to exclude lookups for its own domain */ @@ -290,6 +300,7 @@ int read_reply(struct winbindd_response *response) if ((result2 = read_sock(response->extra_data, extra_data_len)) == -1) { + free_response(response); return -1; } } @@ -299,16 +310,6 @@ int read_reply(struct winbindd_response *response) return result1 + result2; } -/* Free a response structure */ - -void free_response(struct winbindd_response *response) -{ - /* Free any allocated extra_data */ - - if (response) - SAFE_FREE(response->extra_data); -} - /* * send simple types of requests */ diff --git a/source/nsswitch/winbind_nss.c b/source/nsswitch/winbind_nss.c index e7e53a40a10..bb401a00338 100644 --- a/source/nsswitch/winbind_nss.c +++ b/source/nsswitch/winbind_nss.c @@ -178,6 +178,8 @@ winbind_callback(nsd_file_t **rqp, int fd) status = winbindd_get_response(&response); if (status != NSS_STATUS_SUCCESS) { + /* free any extra data area in response structure */ + free_response(&response); nsd_logprintf(NSD_LOG_MIN, "callback (winbind) returning not found\n"); rq->f_status = NS_NOTFOUND; return NSD_NEXT; @@ -193,8 +195,7 @@ winbind_callback(nsd_file_t **rqp, int fd) pw->pw_gecos, pw->pw_dir, pw->pw_shell); - nsd_set_result(rq,NS_SUCCESS,result,strlen(result),VOLATILE); - return NSD_OK; + break; case WINBINDD_GETGRNAM_FROM_GROUP: case WINBINDD_GETGRNAM_FROM_GID: if (gr->num_gr_mem && response.extra_data) @@ -203,11 +204,15 @@ winbind_callback(nsd_file_t **rqp, int fd) members = ""; snprintf(result,1023,"%s:%s:%d:%s\n", gr->gr_name, gr->gr_passwd, gr->gr_gid, members); - nsd_set_result(rq,NS_SUCCESS,result,strlen(result),VOLATILE); - return NSD_OK; + break; + default: + nsd_logprintf(NSD_LOG_MIN, "callback (winbind) - no valid command\n"); + return NSD_NEXT; } - nsd_logprintf(NSD_LOG_MIN, "exit callback (winbind) - no valid command\n"); - return NSD_NEXT; + /* free any extra data area in response structure */ + free_response(&response); + nsd_set_result(rq,NS_SUCCESS,result,strlen(result),VOLATILE); + return NSD_OK; } static int |