Three more pstring removals.
authorJeremy Allison <jra@samba.org>
Mon, 12 Nov 2007 05:46:52 +0000 (21:46 -0800)
committerJeremy Allison <jra@samba.org>
Mon, 12 Nov 2007 05:46:52 +0000 (21:46 -0800)
Jeremy.

source/smbd/chgpasswd.c
source/smbd/process.c
source/smbd/server.c

index d89442150fa65cb46a707f291154afc9f8d3cab9..6e7ef208c1c915a7cb25a90644ab18b65806d54c 100644 (file)
@@ -262,14 +262,18 @@ static int expect(int master, char *issue, char *expected)
 
                        {
                                /* Eat leading/trailing whitespace before match. */
-                               pstring str;
-                               pstrcpy( str, buffer);
-                               trim_char( str, ' ', ' ');
+                               char *str = SMB_STRDUP(buffer);
+                               if (!str) {
+                                       DEBUG(2,("expect: ENOMEM\n"));
+                                       return False;
+                               }
+                               trim_char(str, ' ', ' ');
 
                                if ((match = unix_wild_match(expected, str)) == True) {
                                        /* Now data has started to return, lower timeout. */
                                        timeout = lp_passwd_chat_timeout() * 100;
                                }
+                               SAFE_FREE(str);
                        }
                }
 
index 5601a7fb6e4c40ce7679a2585b94b968acf40242..ffc9e106f60afee614314adc8c66edd24ce24acc 100644 (file)
@@ -1260,13 +1260,18 @@ void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes)
 static void smb_dump(const char *name, int type, const char *data, ssize_t len)
 {
        int fd, i;
-       pstring fname;
-       if (DEBUGLEVEL < 50) return;
+       char *fname = NULL;
+       if (DEBUGLEVEL < 50) {
+               return;
+       }
 
        if (len < 4) len = smb_len(data)+4;
        for (i=1;i<100;i++) {
-               slprintf(fname,sizeof(fname)-1, "/tmp/%s.%d.%s", name, i,
+               asprintf(&fname, "/tmp/%s.%d.%s", name, i,
                                type ? "req" : "resp");
+               if (!fname) {
+                       return;
+               }
                fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644);
                if (fd != -1 || errno != EEXIST) break;
        }
@@ -1277,6 +1282,7 @@ static void smb_dump(const char *name, int type, const char *data, ssize_t len)
                close(fd);
                DEBUG(0,("created %s len %lu\n", fname, (unsigned long)len));
        }
+       SAFE_FREE(fname);
 }
 
 /****************************************************************************
index e89a94599efee951874e113dc3987ad21d2063b7..028dacc27e5cf92c586bef554cdfe716115e6bf3 100644 (file)
@@ -728,8 +728,7 @@ bool reload_services(bool test)
        bool ret;
        
        if (lp_loaded()) {
-               pstring fname;
-               pstrcpy(fname,lp_configfile());
+               char *fname = lp_configfile();
                if (file_exist(fname, NULL) &&
                    !strcsequal(fname, dyn_CONFIGFILE)) {
                        pstrcpy(dyn_CONFIGFILE, fname);