[PATCH 6/6] lanman: don't leak cache_path onto talloc tos

David Disseldorp ddiss at samba.org
Mon Oct 6 10:21:18 MDT 2014


Also check for allocation failures.

Reported-by: Franz Pförtsch <franz.pfoertsch at brose.com>
Signed-off-by: David Disseldorp <ddiss at samba.org>
---
 source3/smbd/lanman.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index ac4873d..641f161 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -1226,12 +1226,19 @@ static int get_session_info(uint32 servertype,
 	char **lines;
 	bool local_list_only;
 	int i;
+	char *slist_cache_path = cache_path(SERVER_LIST);
+	if (slist_cache_path == NULL) {
+		return 0;
+	}
 
-	lines = file_lines_load(cache_path(SERVER_LIST), NULL, 0, NULL);
+	lines = file_lines_load(slist_cache_path, NULL, 0, NULL);
 	if (!lines) {
-		DEBUG(4,("Can't open %s - %s\n",cache_path(SERVER_LIST),strerror(errno)));
+		DEBUG(4, ("Can't open %s - %s\n",
+			  slist_cache_path, strerror(errno)));
+		TALLOC_FREE(slist_cache_path);
 		return 0;
 	}
+	TALLOC_FREE(slist_cache_path);
 
 	/* request for everything is code for request all servers */
 	if (servertype == SV_TYPE_ALL) {
-- 
1.8.4.5



More information about the samba-technical mailing list