s3: Convert is_visible_file to use talloc_asprintf instead of malloc
authorTim Prouty <tprouty@samba.org>
Thu, 18 Jun 2009 18:38:42 +0000 (11:38 -0700)
committerTim Prouty <tprouty@samba.org>
Thu, 25 Jun 2009 04:15:24 +0000 (21:15 -0700)
source3/smbd/dir.c

index f5a9e22d1477d9c8c2c2d4cb40c97e93b8c648cd..fb246cdf8c5755ce7e320e6142c8a45129f09556 100644 (file)
@@ -1043,16 +1043,17 @@ bool is_visible_file(connection_struct *conn, const char *dir_path,
        if (hide_unreadable || hide_unwriteable || hide_special) {
                char *entry = NULL;
 
-               if (asprintf(&entry, "%s/%s", dir_path, name) == -1) {
-                       return False;
+               entry = talloc_asprintf(talloc_tos(), "%s/%s", dir_path, name);
+               if (!entry)
+                       return false;
                }
 
                /* If it's a dfs symlink, ignore _hide xxxx_ options */
                if (lp_host_msdfs() &&
                                lp_msdfs_root(SNUM(conn)) &&
                                is_msdfs_link(conn, entry, NULL)) {
-                       SAFE_FREE(entry);
-                       return True;
+                       TALLOC_FREE(entry);
+                       return true;
                }
 
                /* If the file name does not exist, there's no point checking
@@ -1061,34 +1062,34 @@ bool is_visible_file(connection_struct *conn, const char *dir_path,
                 */
                if (!VALID_STAT(*pst) && (SMB_VFS_STAT(conn, entry, pst) != 0))
                {
-                       SAFE_FREE(entry);
-                       return True;
+                       TALLOC_FREE(entry);
+                       return true;
                }
 
                /* Honour _hide unreadable_ option */
                if (hide_unreadable && !user_can_read_file(conn, entry)) {
                        DEBUG(10,("is_visible_file: file %s is unreadable.\n",
                                 entry ));
-                       SAFE_FREE(entry);
-                       return False;
+                       TALLOC_FREE(entry);
+                       return false;
                }
                /* Honour _hide unwriteable_ option */
                if (hide_unwriteable && !user_can_write_file(conn, entry, pst)) {
                        DEBUG(10,("is_visible_file: file %s is unwritable.\n",
                                 entry ));
-                       SAFE_FREE(entry);
-                       return False;
+                       TALLOC_FREE(entry);
+                       return false;
                }
                /* Honour _hide_special_ option */
                if (hide_special && file_is_special(conn, entry, pst)) {
                        DEBUG(10,("is_visible_file: file %s is special.\n",
                                 entry ));
-                       SAFE_FREE(entry);
-                       return False;
+                       TALLOC_FREE(entry);
+                       return false;
                }
-               SAFE_FREE(entry);
+               TALLOC_FREE(entry);
        }
-       return True;
+       return true;
 }
 
 static int smb_Dir_destructor(struct smb_Dir *dirp)