From: Volker Lendecke Date: Tue, 24 Apr 2012 12:23:11 +0000 (+0200) Subject: s3: Simplify check_reduced_name a bit X-Git-Tag: samba-4.0.0alpha20~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d01099acc77d433f06f36f854f27fd9f1e43f05;p=thirdparty%2Fsamba.git s3: Simplify check_reduced_name a bit It's pointless to do a talloc_asprintf with a SMB_STRDUP on the result. Use asprintf directly. Autobuild-User: Volker Lendecke Autobuild-Date: Tue Apr 24 18:18:05 CEST 2012 on sn-devel-104 --- diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index b330c03bfc7..6c9692a65b6 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -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: