s3: Simplify check_reduced_name a bit
authorVolker Lendecke <vl@samba.org>
Tue, 24 Apr 2012 12:23:11 +0000 (14:23 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 24 Apr 2012 16:18:05 +0000 (18:18 +0200)
It's pointless to do a talloc_asprintf with a SMB_STRDUP on the
result. Use asprintf directly.

Autobuild-User: Volker Lendecke <vl@samba.org>
Autobuild-Date: Tue Apr 24 18:18:05 CEST 2012 on sn-devel-104

source3/smbd/vfs.c

index b330c03bfc7e2a4a29fd79aa2522e9f8684ccfe6..6c9692a65b6bc4b85b576a3aa3784d2d08b51da7 100644 (file)
@@ -1089,6 +1089,7 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
                                char *dir_name = NULL;
                                const char *last_component = NULL;
                                char *new_name = NULL;
+                               int ret;
 
                                /* Last component didn't exist.
                                   Remove it and try and canonicalise
@@ -1114,18 +1115,13 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
                                                nt_errstr(status)));
                                        return status;
                                }
-                               new_name = talloc_asprintf(ctx,
-                                               "%s/%s",
-                                               resolved_name,
-                                               last_component);
-                               if (!new_name) {
-                                       return NT_STATUS_NO_MEMORY;
-                               }
+                               ret = asprintf(&new_name, "%s/%s",
+                                              resolved_name, last_component);
                                SAFE_FREE(resolved_name);
-                               resolved_name = SMB_STRDUP(new_name);
-                               if (!resolved_name) {
+                               if (ret == -1) {
                                        return NT_STATUS_NO_MEMORY;
                                }
+                               resolved_name = new_name;
                                break;
                        }
                        default: