summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZach Loafman <zachary.loafman@isilon.com>2009-08-25 10:46:37 -0700
committerTim Prouty <tprouty@samba.org>2009-08-25 13:01:57 -0700
commit808a0d44f84ed668c906eaa6777d2c0743351560 (patch)
tree66ea0703d3347dd231332ae4165163b9d5efc9df
parent1df18922c613d2d3c8c23b919e435cb1de915eaa (diff)
downloadsamba-808a0d44f84ed668c906eaa6777d2c0743351560.tar.gz
samba-808a0d44f84ed668c906eaa6777d2c0743351560.tar.bz2
samba-808a0d44f84ed668c906eaa6777d2c0743351560.zip
Allow for name array strings that don't end in a slash
Fix set_namearray to allow for strings that don't end in a slash. Also remove unnecessary strdup()s. Signed-off-by: Tim Prouty <tprouty@samba.org>
-rw-r--r--source3/lib/util.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 74b792180a..ae630826d4 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1691,7 +1691,7 @@ bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensit
void set_namearray(name_compare_entry **ppname_array, const char *namelist)
{
char *name_end;
- const char *nameptr = namelist;
+ char *nameptr = (char *)namelist;
int num_entries = 0;
int i;
@@ -1711,12 +1711,14 @@ void set_namearray(name_compare_entry **ppname_array, const char *namelist)
nameptr++;
continue;
}
- /* find the next / */
- name_end = strchr_m(nameptr, '/');
+ /* anything left? */
+ if ( *nameptr == '\0' )
+ break;
- /* oops - the last check for a / didn't find one. */
+ /* find the next '/' or consume remaining */
+ name_end = strchr_m(nameptr, '/');
if (name_end == NULL)
- break;
+ name_end = (char *)nameptr + strlen(nameptr);
/* next segment please */
nameptr = name_end + 1;
@@ -1732,7 +1734,7 @@ void set_namearray(name_compare_entry **ppname_array, const char *namelist)
}
/* Now copy out the names */
- nameptr = namelist;
+ nameptr = (char *)namelist;
i = 0;
while(*nameptr) {
if ( *nameptr == '/' ) {
@@ -1740,14 +1742,17 @@ void set_namearray(name_compare_entry **ppname_array, const char *namelist)
nameptr++;
continue;
}
- /* find the next / */
- if ((name_end = strchr_m(nameptr, '/')) != NULL)
- *name_end = 0;
-
- /* oops - the last check for a / didn't find one. */
- if(name_end == NULL)
+ /* anything left? */
+ if ( *nameptr == '\0' )
break;
+ /* find the next '/' or consume remaining */
+ name_end = strchr_m(nameptr, '/');
+ if (name_end)
+ *name_end = '\0';
+ else
+ name_end = nameptr + strlen(nameptr);
+
(*ppname_array)[i].is_wild = ms_has_wild(nameptr);
if(((*ppname_array)[i].name = SMB_STRDUP(nameptr)) == NULL) {
DEBUG(0,("set_namearray: malloc fail (1)\n"));