s3:lib: Rewrite synthetic_smb_fname_split() to use split_stream_filename().
authorJeremy Allison <jra@samba.org>
Wed, 9 Mar 2016 23:45:55 +0000 (15:45 -0800)
committerJeremy Allison <jra@samba.org>
Thu, 10 Mar 2016 19:55:09 +0000 (20:55 +0100)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
source3/lib/filename_util.c

index 1084c21be7d022260f8e478437961d749b31a144..bdb24c5c6feae41dac8b44d1ac909961523413db 100644 (file)
@@ -70,35 +70,33 @@ struct smb_filename *synthetic_smb_fname(TALLOC_CTX *mem_ctx,
 }
 
 /**
- * XXX: This is temporary and there should be no callers of this once
- * smb_filename is plumbed through all path based operations.
+ * There are a few legitimate users of this.
  */
 struct smb_filename *synthetic_smb_fname_split(TALLOC_CTX *ctx,
                                               const char *fname,
                                               const SMB_STRUCT_STAT *psbuf)
 {
-       const char *stream_name = NULL;
+       char *stream_name = NULL;
        char *base_name = NULL;
        struct smb_filename *ret;
+       bool ok;
 
-       if (!lp_posix_pathnames()) {
-               stream_name = strchr_m(fname, ':');
-       }
-
-       /* Setup the base_name/stream_name. */
-       if (stream_name) {
-               base_name = talloc_strndup(ctx, fname,
-                                          PTR_DIFF(stream_name, fname));
-       } else {
-               base_name = talloc_strdup(ctx, fname);
+       if (lp_posix_pathnames()) {
+               /* No stream name looked for. */
+               return synthetic_smb_fname(ctx, fname, NULL, psbuf);
        }
 
-       if (!base_name) {
+       ok = split_stream_filename(ctx,
+                               fname,
+                               &base_name,
+                               &stream_name);
+       if (!ok) {
                return NULL;
        }
 
        ret = synthetic_smb_fname(ctx, base_name, stream_name, psbuf);
        TALLOC_FREE(base_name);
+       TALLOC_FREE(stream_name);
        return ret;
 }