- Make ReadDirName return a const char*.
authorAndrew Bartlett <abartlet@samba.org>
Sun, 16 Mar 2003 13:21:12 +0000 (13:21 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 16 Mar 2003 13:21:12 +0000 (13:21 +0000)
 - Consequential changes from that

 - mark our fstring/pstring assumptions in function prototypes

Andrew Bartlett
(This used to be commit fe2bc64bc439b27387b8f326b0f4f3bfcc3d04a1)

source3/client/client.c
source3/lib/util.c
source3/smbd/chgpasswd.c
source3/smbd/mangle.c
source3/smbd/mangle_hash2.c
source3/smbd/mangle_map.c
source3/smbd/trans2.c

index 99fc779a9e006cd46e65d8cf0cf019beac641802..1248c256591429dc2d662fb0b50cb9c750fab7e9 100644 (file)
@@ -1291,7 +1291,7 @@ static int file_find(struct file_list **list, const char *directory,
         int ret;
         char *path;
        BOOL isdir;
-       char *dname;
+       const char *dname;
 
         dir = opendir(directory);
        if (!dir) return -1;
index 1f300a28157a660e4a648239a64981cc064b88c1..421631033599f5bcece81d69e7278b0f419cc427 100644 (file)
@@ -1435,7 +1435,7 @@ void smb_panic(const char *why)
  A readdir wrapper which just returns the file name.
 ********************************************************************/
 
-char *readdirname(DIR *p)
+const char *readdirname(DIR *p)
 {
        SMB_STRUCT_DIRENT *ptr;
        char *dname;
index 401ab131adb7bf306247b9ce1e5c5ff6ffcb0f2a..31c4fa7cc9bf286a5b8c4fa9185611ed201f4cfc 100644 (file)
@@ -64,7 +64,7 @@ static int findpty(char **slave)
        int master;
        static fstring line;
        DIR *dirp;
-       char *dpname;
+       const char *dpname;
 
 #if defined(HAVE_GRANTPT)
        /* Try to open /dev/ptmx. If that fails, fall through to old method. */
index f5c703a5bff1980450b88d70f7ef15adf3da614c..c5d7582c0336b3556ae01958e0c3149b4af564ea 100644 (file)
@@ -107,7 +107,7 @@ BOOL mangle_check_cache(char *s)
    map a long filename to a 8.3 name. 
  */
 
-void mangle_map(char *OutName, BOOL need83, BOOL cache83, int snum)
+void mangle_map(pstring OutName, BOOL need83, BOOL cache83, int snum)
 {
        /* name mangling can be disabled for speed, in which case
           we just truncate the string */
index eda509214d8a63090537cdf87d6c8f1a4be6e7e2..cdce28e1bd858d9cf03cd77f1d02e1ab71f42f48 100644 (file)
@@ -484,7 +484,7 @@ static BOOL is_legal_name(const char *name)
 
   the name parameter must be able to hold 13 bytes
 */
-static void name_map(char *name, BOOL need83, BOOL cache83)
+static void name_map(fstring name, BOOL need83, BOOL cache83)
 {
        char *dot_p;
        char lead_chars[7];
index 5ae3ebd174b5cd2580e2f8ac90c8cb7dc80cc5d9..9e798fd41b46ce6d5912d362346417bdc4c28b06 100644 (file)
@@ -201,7 +201,7 @@ static void mangled_map(char *s, const char *MangledMap)
   front end routine to the mangled map code 
   personally I think that the whole idea of "mangled map" is completely bogus
 */
-void mangle_map_filename(char *fname, int snum)
+void mangle_map_filename(fstring fname, int snum)
 {
        char *map;
 
index bea09e9e373a4bdeee2f06d7c23d066c72709fc3..4129852f778370353f5b213dfeb397ca0f1d1de6 100644 (file)
@@ -460,7 +460,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
                                 BOOL *out_of_space, BOOL *got_exact_match,
                                 int *last_name_off)
 {
-       char *dname;
+       const char *dname;
        BOOL found = False;
        SMB_STRUCT_STAT sbuf;
        pstring mask;
@@ -1173,7 +1173,8 @@ resume_key = %d resume name = %s continue=%d level = %d\n",
                 */
 
                int current_pos, start_pos;
-               char *dname = NULL;
+               const char *dname = NULL;
+               pstring dname_pstring;
                void *dirptr = conn->dirptr;
                start_pos = TellDir(dirptr);
                for(current_pos = start_pos; current_pos >= 0; current_pos--) {
@@ -1181,21 +1182,24 @@ resume_key = %d resume name = %s continue=%d level = %d\n",
 
                        SeekDir(dirptr, current_pos);
                        dname = ReadDirName(dirptr);
+                       if (dname) {
+                               /*
+                                * Remember, mangle_map is called by
+                                * get_lanman2_dir_entry(), so the resume name
+                                * could be mangled. Ensure we do the same
+                                * here.
+                                */
+                               
+                               /* make sure we get a copy that mangle_map can modify */
 
-                       /*
-                        * Remember, mangle_map is called by
-                        * get_lanman2_dir_entry(), so the resume name
-                        * could be mangled. Ensure we do the same
-                        * here.
-                        */
-
-                       if(dname != NULL)
-                               mangle_map( dname, False, True, SNUM(conn));
-
-                       if(dname && strcsequal( resume_name, dname)) {
-                               SeekDir(dirptr, current_pos+1);
-                               DEBUG(7,("call_trans2findnext: got match at pos %d\n", current_pos+1 ));
-                               break;
+                               pstrcpy(dname_pstring, dname);
+                               mangle_map( dname_pstring, False, True, SNUM(conn));
+                               
+                               if(strcsequal( resume_name, dname_pstring)) {
+                                       SeekDir(dirptr, current_pos+1);
+                                       DEBUG(7,("call_trans2findnext: got match at pos %d\n", current_pos+1 ));
+                                       break;
+                               }
                        }
                }
 
@@ -1215,13 +1219,17 @@ resume_key = %d resume name = %s continue=%d level = %d\n",
                                 * here.
                                 */
 
-                               if(dname != NULL)
-                                       mangle_map( dname, False, True, SNUM(conn));
+                               if(dname) {
+                                       /* make sure we get a copy that mangle_map can modify */
+                                       
+                                       pstrcpy(dname_pstring, dname);
+                                       mangle_map(dname_pstring, False, True, SNUM(conn));
 
-                               if(dname && strcsequal( resume_name, dname)) {
-                                       SeekDir(dirptr, current_pos+1);
-                                       DEBUG(7,("call_trans2findnext: got match at pos %d\n", current_pos+1 ));
-                                       break;
+                                       if(strcsequal( resume_name, dname_pstring)) {
+                                               SeekDir(dirptr, current_pos+1);
+                                               DEBUG(7,("call_trans2findnext: got match at pos %d\n", current_pos+1 ));
+                                               break;
+                                       }
                                }
                        } /* end for */
                } /* end if current_pos */
@@ -1269,7 +1277,6 @@ resume_key = %d resume name = %s continue=%d level = %d\n",
                dptr_close(&dptr_num); /* This frees up the saved mask */
        }
 
-
        /* Set up the return parameter block */
        SSVAL(params,0,numentries);
        SSVAL(params,2,finished);