Following info from TAKAHASHI Motonobu <monyo@samba.gr.jp>,
authorJeremy Allison <jra@samba.org>
Thu, 21 Jun 2001 01:01:15 +0000 (01:01 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 21 Jun 2001 01:01:15 +0000 (01:01 +0000)
Samba Users Group Japan, ensure that we don't use dos_to_unix(xx,True),
but always use dos_to_unix(xx,False) to prevent overwriting.
Jeremy.
(This used to be commit 244aec8ea623fec828add3ab09c5003bf32bd5c7)

source3/libsmb/clirap.c
source3/libsmb/clistr.c
source3/smbd/message.c
source3/smbd/reply.c

index 5d41af13f90ebd32374ba33431cfc4fc479c5638..5050caf0732738ffe3e0b2ef4911786723e22e10 100644 (file)
@@ -179,9 +179,12 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co
                                        int type = SVAL(p,14);
                                        int comment_offset = IVAL(p,16) & 0xFFFF;
                                        char *cmnt = comment_offset?(rdata+comment_offset-converter):"";
-                                       dos_to_unix(sname,True);
-                                       dos_to_unix(cmnt,True);
-                                       fn(sname, type, cmnt, state);
+                                       pstring s1, s2;
+
+                                       pstrcpy(s1, dos_to_unix(sname, False));
+                                       pstrcpy(s2, dos_to_unix(cmnt, False));
+
+                                       fn(s1, type, s2, state);
                                }
                        } else {
                                DEBUG(4,("NetShareEnum res=%d\n", res));
@@ -256,13 +259,15 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
                                char *sname = p;
                                int comment_offset = (IVAL(p,22) & 0xFFFF)-converter;
                                char *cmnt = comment_offset?(rdata+comment_offset):"";
+                               pstring s1, s2;
+
                                if (comment_offset < 0 || comment_offset > rdrcnt) continue;
 
                                stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY;
 
-                               dos_to_unix(sname, True);
-                               dos_to_unix(cmnt, True);
-                               fn(sname, stype, cmnt, state);
+                               pstrcpy(s1, dos_to_unix(sname, False));
+                               pstrcpy(s2, dos_to_unix(cmnt, False));
+                               fn(s1, stype, s2, state);
                        }
                }
        }
index 02257975380ee56ee941e4f30bb18a7e88c941e3..887b5e84c1b395532fc2f81e4acd858e7569bed0 100644 (file)
@@ -112,7 +112,8 @@ int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len
                        memcpy(dest, src, len);
                        dest[len] = 0;
                }
-               if (flags & STR_CONVERT) dos_to_unix(dest,True);
+               if (flags & STR_CONVERT) 
+                       safe_strcpy(dest,dos_to_unix(dest,False),dest_len);
                return len;
        }
 
@@ -129,7 +130,8 @@ int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len
                *dest++ = 0;
                len = src_len;
        }
-       if (flags & STR_CONVERT) dos_to_unix(dest,True);
+       if (flags & STR_CONVERT)
+               safe_strcpy(dest,dos_to_unix(dest,False),dest_len);
        return len;
 }
 
index 98eb336c0a1c25e825ae70ed1192f9fb53e64ef9..a023650c74abd321a230e9b0925f63f704989900 100644 (file)
@@ -61,13 +61,12 @@ static void msg_deliver(void)
   }
 
   /*
-   * Incoming message is in DOS codepage format. Convert to UNIX in
-   * place.
+   * Incoming message is in DOS codepage format. Convert to UNIX.
    */
 
   if(msgpos > 0) {
     msgbuf[msgpos] = '\0'; /* Ensure null terminated. */
-    dos_to_unix(msgbuf,True);
+    pstrcpy(msgbuf,dos_to_unix(msgbuf,False));
   }
 
   for (i=0;i<msgpos;) {
index 2f9898616c9f2fb10fd7bcc041d5f68958560ec9..e0b0cea2d3369afc8dbec086250ca827d572accf 100644 (file)
@@ -209,9 +209,9 @@ int reply_tcon(connection_struct *conn,
         * Ensure the user and password names are in UNIX codepage format.
         */
        
-       dos_to_unix(user,True);
+       pstrcpy(user,dos_to_unix(user,False));
        if (!doencrypt)
-       dos_to_unix(password,True);
+       pstrcpy(password,dos_to_unix(password,False));
 
        /*
         * Pass the user through the NT -> unix user mapping
@@ -797,8 +797,8 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int
        * Ensure the plaintext passwords are in UNIX format.
        */
       if(!doencrypt) {
-        dos_to_unix(smb_apasswd,True);
-        dos_to_unix(smb_ntpasswd,True);
+        pstrcpy(smb_apasswd,dos_to_unix(smb_apasswd,False));
+        pstrcpy(smb_ntpasswd,dos_to_unix(smb_ntpasswd,False));
       }
 
     } else {
@@ -808,7 +808,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int
       /*
        * Ensure the plaintext password is in UNIX format.
        */
-      dos_to_unix(smb_apasswd,True);
+      pstrcpy(smb_apasswd,dos_to_unix(smb_apasswd,False));
       
       /* trim the password */
       smb_apasslen = strlen(smb_apasswd);