use asprintf for hideunreadable option
authorAndrew Tridgell <tridge@samba.org>
Sat, 28 Apr 2001 12:43:15 +0000 (12:43 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 28 Apr 2001 12:43:15 +0000 (12:43 +0000)
source/smbd/dir.c

index 1d497574a6d0acbd5159ef3db48755f3c57a17a1..fa9cbdc4a2a498742952e3e9062cb68805f9a9e2 100644 (file)
@@ -727,21 +727,15 @@ void *OpenDir(connection_struct *conn, char *name, BOOL use_veto)
     if (use_veto && conn && IS_VETO_PATH(conn, n)) continue;
 
     /* Honour _hide unreadable_ option */
-    if (conn && lp_hideunreadable(SNUM(conn)))
-    {
-      char *entry;
-      int ret;
+    if (conn && lp_hideunreadable(SNUM(conn))) {
+           char *entry;
+           int ret=0;
       
-      entry = (char *)malloc(PATH_MAX);
-      if (!entry) {
-        DEBUG(0,("Out of memory in OpenDir\n"));
-        conn->vfs_ops.closedir(conn,p);
-        return(NULL);
-      }
-      slprintf(entry, PATH_MAX, "%s/%s/%s", conn->origpath, name, n);
-      ret = user_can_read_file(conn, entry);
-      free(entry);
-      if (!ret) continue;
+           if (asprintf(&entry, "%s/%s/%s", conn->origpath, name, n) > 0) {
+                   ret = user_can_read_file(conn, entry);
+                   free(entry);
+           }
+           if (!ret) continue;
     }
 
     if (used + l > dirp->mallocsize) {