mangle.c: Fixed bug that caused string to run off the end of the mangled map.
authorJeremy Allison <jra@samba.org>
Thu, 28 Aug 1997 18:59:52 +0000 (18:59 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 28 Aug 1997 18:59:52 +0000 (18:59 +0000)
server.c: Changed comparison from dname to name2 - seems correct - don't know why
          I changed it originally. hmmmmm.
trans2.c: Made lanman2 code more similar to scan_directory(). I should
          make the trans2 code call scan_dir as they are so similar.
Jeremy(jallison@whistle.com).

source/smbd/mangle.c
source/smbd/server.c
source/smbd/trans2.c

index 96e787b07fb14c1853dd638286b0b2471d7eee13..a08402a85ea43e00a72858fc20c815f4eb6ee127 100644 (file)
@@ -414,9 +414,9 @@ static void do_fwd_mangled_map(char *s, char *MangledMap)
   while (*start) {
     while ((*start) && (*start != '('))
       start++;
-    start++;                    /* Skip the ( */
     if (!*start)
       continue;                 /* Always check for the end. */
+    start++;                    /* Skip the ( */
     end = start;                /* Search for the ' ' or a ')' */
     DEBUG(5,("Start of first in pair '%s'\n", start));
     while ((*end) && !((*end == ' ') || (*end == ')')))
index 4259bda958b5aa921b41c7b3c870180fb22a6e4b..93724a98612af9d1d52e48ff9d95c700d4e59aff 100644 (file)
@@ -397,7 +397,7 @@ static BOOL scan_directory(char *path, char *name,int cnum,BOOL docache)
       if (!name_map_mangle(name2,False,SNUM(cnum))) continue;
 
       if ((mangled && mangled_equal(name,name2))
-         || fname_equal(name, dname))
+         || fname_equal(name, name2)) /* name2 here was changed to dname - since 1.9.16p2 - not sure of reason (jra) */
        {
          /* we've found the file, change it's name and return */
          if (docache) DirCacheAdd(path,name,dname,SNUM(cnum));
index 80529240590ffaebde78f3a06c3cfbaf64619a16..28bff0884377d1f2bb60cff1c786b1cd3b8b3af2 100644 (file)
@@ -329,7 +329,8 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
 
       strcpy(fname,dname);      
 
-      if(mask_match(fname, mask, case_sensitive, True))
+      if(name_map_mangle(fname,False,SNUM(cnum)) &&
+         mask_match(fname, mask, case_sensitive, True))
        {
          BOOL isdots = (strequal(fname,"..") || strequal(fname,"."));
          if (dont_descend && !isdots)
@@ -341,7 +342,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
          strcpy(pathreal,Connections[cnum].dirpath);
           if(needslash)
            strcat(pathreal,"/");
-         strcat(pathreal,fname);
+         strcat(pathreal,dname);
          if (sys_stat(pathreal,&sbuf) != 0) 
            {
              DEBUG(5,("get_lanman2_dir_entry:Couldn't stat [%s] (%s)\n",pathreal,strerror(errno)));
@@ -368,13 +369,9 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
        }
     }
 
-
-
   p = pdata;
   nameptr = p;
 
-  name_map_mangle(fname,False,SNUM(cnum));
-
   nt_extmode = mode ? mode : NT_FILE_ATTRIBUTE_NORMAL;
 
   switch (info_level)