svn commit: samba r13387 - in branches/SAMBA_4_0/source/libcli: .

jpeach at samba.org jpeach at samba.org
Wed Feb 8 05:13:12 GMT 2006


Author: jpeach
Date: 2006-02-08 05:13:11 +0000 (Wed, 08 Feb 2006)
New Revision: 13387

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=13387

Log:
Make sure smbcli_parse_unc reports a failure for strings of
the form //server. Make sure failure cases are well-defined.

Modified:
   branches/SAMBA_4_0/source/libcli/cliconnect.c


Changeset:
Modified: branches/SAMBA_4_0/source/libcli/cliconnect.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/cliconnect.c	2006-02-08 04:46:43 UTC (rev 13386)
+++ branches/SAMBA_4_0/source/libcli/cliconnect.c	2006-02-08 05:13:11 UTC (rev 13387)
@@ -177,25 +177,29 @@
 }
 
 /* Insert a NULL at the first separator of the given path and return a pointer
- * to the location it was inserted at.
+ * to the remainder of the string.
  */
 static char *
 terminate_path_at_separator(char * path)
 {
 	char * p;
 
+	if (!path) {
+		return NULL;
+	}
+
 	if ((p = strchr_m(path, '/'))) {
-	    *p = '\0';
-	    return(p);
+		*p = '\0';
+		return p + 1;
 	}
 
 	if ((p = strchr_m(path, '\\'))) {
-	    *p = '\0';
-	    return(p);
+		*p = '\0';
+		return p + 1;
 	}
 	
-	/* No terminator. Return pointer to the last byte. */
-	return(p + strlen(path));
+	/* No separator. */
+	return NULL;
 }
 
 /*
@@ -206,6 +210,8 @@
 {
 	char *p;
 
+	*hostname = *sharename = NULL;
+
 	if (strncmp(unc_name, "\\\\", 2) &&
 	    strncmp(unc_name, "//", 2)) {
 		return False;
@@ -214,10 +220,19 @@
 	*hostname = talloc_strdup(mem_ctx, &unc_name[2]);
 	p = terminate_path_at_separator(*hostname);
 
-	*sharename = talloc_strdup(mem_ctx, p+1);
-	p = terminate_path_at_separator(*sharename);
+	if (p && *p) {
+		*sharename = talloc_strdup(mem_ctx, p);
+		terminate_path_at_separator(*sharename);
+	}
 
-	return True;
+	if (*hostname && *sharename) {
+		return True;
+	}
+
+	talloc_free(*hostname);
+	talloc_free(*sharename);
+	*hostname = *sharename = NULL;
+	return False;
 }
 
 



More information about the samba-cvs mailing list