lanman: don't leak cache_path onto talloc tos
authorDavid Disseldorp <ddiss@samba.org>
Mon, 6 Oct 2014 16:21:18 +0000 (18:21 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 6 Oct 2014 19:41:22 +0000 (21:41 +0200)
Also check for allocation failures.

Reported-by: Franz Pförtsch <franz.pfoertsch@brose.com>
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Oct  6 21:41:22 CEST 2014 on sn-devel-104

source3/smbd/lanman.c

index ac4873decca0d07c05f17b37100a25768ca20af9..641f161f7642f2e6f095267ceb52f6c06b6f4b92 100644 (file)
@@ -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) {