Fix a number of client-side fstring/pstring mixups.
authorAndrew Bartlett <abartlet@samba.org>
Sat, 11 Jan 2003 12:04:14 +0000 (12:04 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 11 Jan 2003 12:04:14 +0000 (12:04 +0000)
Andrew Bartlett
(This used to be commit fe1cc779d5ea77e87dbc0e2edf7c34a354fee6e0)

source3/client/client.c
source3/libsmb/clilist.c
source3/libsmb/smbencrypt.c
source3/torture/locktest.c
source3/torture/locktest2.c
source3/torture/masktest.c
source3/torture/torture.c
source3/utils/nmblookup.c
source3/utils/smbcacls.c

index 44fcdb0e8de7462a2a2aa2e62b3cea61b125db25..f7c076b79e534685b0fe4bffb2581eec12e4abc2 100644 (file)
@@ -2978,7 +2978,7 @@ static void remember_query_host(const char *arg,
                        }
                        break;
                case 'D':
-                       pstrcpy(base_directory,optarg);
+                       fstrcpy(base_directory,optarg);
                        break;
                case 'c':
                        cmdstr = optarg;
index 4a1737af497fb3acb6bc0947fb9eb91a712b815e..89ab5d6414b2e56ed1eea0873dd57bfe996dc334 100644 (file)
@@ -324,9 +324,11 @@ static int interpret_short_filename(struct cli_state *cli, char *p,file_info *fi
        finfo->mtime = finfo->atime = finfo->ctime;
        finfo->size = IVAL(p,26);
        clistr_pull(cli, finfo->name, p+30, sizeof(finfo->name), 12, STR_ASCII);
-       if (strcmp(finfo->name, "..") && strcmp(finfo->name, "."))
-               fstrcpy(finfo->short_name,finfo->name);
-       
+       if (strcmp(finfo->name, "..") && strcmp(finfo->name, ".")) {
+               strncpy(finfo->short_name,finfo->name, sizeof(finfo->short_name)-1);
+               finfo->short_name[sizeof(finfo->short_name)-1] = '\0';
+       }
+
        return(DIR_STRUCT_SIZE);
 }
 
index 42250fc19c949f32e53465c75a31e63dd4d9edf8..06871104a4c0f3a5a7984dc46c2ea48f4a1dbe8a 100644 (file)
@@ -122,33 +122,33 @@ BOOL ntv2_owf_gen(const uchar owf[16],
        smb_ucs2_t *user;
        smb_ucs2_t *domain;
        
-       int user_byte_len;
-       int domain_byte_len;
+       size_t user_byte_len;
+       size_t domain_byte_len;
 
        HMACMD5Context ctx;
 
        user_byte_len = push_ucs2_allocate(&user, user_in);
-       if (user_byte_len < 0) {
-               DEBUG(0, ("push_ucs2_allocate() for user returned %d (probably malloc() failure)\n", user_byte_len));
+       if (user_byte_len == (size_t)-1) {
+               DEBUG(0, ("push_uss2_allocate() for user returned -1 (probably malloc() failure)\n"));
                return False;
        }
 
        domain_byte_len = push_ucs2_allocate(&domain, domain_in);
-       if (domain_byte_len < 0) {
-               DEBUG(0, ("push_ucs2_allocate() for domain returned %d (probably malloc() failure)\n", domain_byte_len));
+       if (domain_byte_len == (size_t)-1) {
+               DEBUG(0, ("push_uss2_allocate() for domain returned -1 (probably malloc() failure)\n"));
                return False;
        }
 
        strupper_w(user);
        strupper_w(domain);
 
+       SMB_ASSERT(user_byte_len >= 2);
+       SMB_ASSERT(domain_byte_len >= 2);
+
        /* We don't want null termination */
        user_byte_len = user_byte_len - 2;
        domain_byte_len = domain_byte_len - 2;
        
-       SMB_ASSERT(user_byte_len >= 0);
-       SMB_ASSERT(domain_byte_len >= 0);
-
        hmac_md5_init_limK_to_64(owf, 16, &ctx);
        hmac_md5_update((const unsigned char *)user, user_byte_len, &ctx);
        hmac_md5_update((const unsigned char *)domain, domain_byte_len, &ctx);
index a62f7af1ad693b18bb71b3ccfe8ceed2dac42ce3..5f9a63802b31d351ed0b343c5ee87e6af0e4f9a0 100644 (file)
@@ -193,14 +193,14 @@ static struct cli_state *connect_one(char *share, int snum)
        if (!got_pass) {
                char *pass = getpass("Password: ");
                if (pass) {
-                       pstrcpy(password[0], pass);
-                       pstrcpy(password[1], pass);
+                       fstrcpy(password[0], pass);
+                       fstrcpy(password[1], pass);
                }
        }
 
        if (got_pass == 1) {
-               pstrcpy(password[1], password[0]);
-               pstrcpy(username[1], username[0]);
+               fstrcpy(password[1], password[0]);
+               fstrcpy(username[1], username[0]);
        }
 
        if (!cli_session_setup(c, username[snum], 
@@ -591,8 +591,8 @@ static void usage(void)
        load_interfaces();
 
        if (getenv("USER")) {
-               pstrcpy(username[0],getenv("USER"));
-               pstrcpy(username[1],getenv("USER"));
+               fstrcpy(username[0],getenv("USER"));
+               fstrcpy(username[1],getenv("USER"));
        }
 
        seed = time(NULL);
@@ -613,11 +613,11 @@ static void usage(void)
                                d_printf("Max of 2 usernames\n");
                                exit(1);
                        }
-                       pstrcpy(username[got_pass],optarg);
+                       fstrcpy(username[got_pass],optarg);
                        p = strchr_m(username[got_pass],'%');
                        if (p) {
                                *p = 0;
-                               pstrcpy(password[got_pass], p+1);
+                               fstrcpy(password[got_pass], p+1);
                                got_pass++;
                        }
                        break;
index 3166d6e326423846967e1f533285911f8ac016f5..97844b5609ecfbea1ad374ab0862d453079592f4 100644 (file)
@@ -169,7 +169,7 @@ static struct cli_state *connect_one(char *share)
        if (!got_pass) {
                char *pass = getpass("Password: ");
                if (pass) {
-                       pstrcpy(password, pass);
+                       fstrcpy(password, pass);
                }
        }
 
@@ -504,7 +504,7 @@ static void usage(void)
        load_interfaces();
 
        if (getenv("USER")) {
-               pstrcpy(username,getenv("USER"));
+               fstrcpy(username,getenv("USER"));
        }
 
        seed = time(NULL);
@@ -512,11 +512,11 @@ static void usage(void)
        while ((opt = getopt(argc, argv, "U:s:ho:aAW:O")) != EOF) {
                switch (opt) {
                case 'U':
-                       pstrcpy(username,optarg);
+                       fstrcpy(username,optarg);
                        p = strchr_m(username,'%');
                        if (p) {
                                *p = 0;
-                               pstrcpy(password, p+1);
+                               fstrcpy(password, p+1);
                                got_pass = 1;
                        }
                        break;
index 9b83619e8582ed2316afff39990fd7fb95ba18a5..df0a047aff32eb5461a1c734f045cab37679711a 100644 (file)
@@ -213,7 +213,7 @@ struct cli_state *connect_one(char *share)
        if (!got_pass) {
                char *pass = getpass("Password: ");
                if (pass) {
-                       pstrcpy(password, pass);
+                       fstrcpy(password, pass);
                }
        }
 
@@ -456,7 +456,7 @@ static void usage(void)
        load_interfaces();
 
        if (getenv("USER")) {
-               pstrcpy(username,getenv("USER"));
+               fstrcpy(username,getenv("USER"));
        }
 
        seed = time(NULL);
@@ -479,11 +479,11 @@ static void usage(void)
                        max_protocol = interpret_protocol(optarg, max_protocol);
                        break;
                case 'U':
-                       pstrcpy(username,optarg);
+                       fstrcpy(username,optarg);
                        p = strchr_m(username,'%');
                        if (p) {
                                *p = 0;
-                               pstrcpy(password, p+1);
+                               fstrcpy(password, p+1);
                                got_pass = 1;
                        }
                        break;
index 5b25002213912148edd16f829c8a263c751dda90..5466d8ef9ee36f56c32c01f375709fecbf65c288 100644 (file)
@@ -4055,7 +4055,7 @@ static void usage(void)
        get_myname(myname);
 
        if (*username == 0 && getenv("LOGNAME")) {
-         pstrcpy(username,getenv("LOGNAME"));
+         fstrcpy(username,getenv("LOGNAME"));
        }
 
        argc--;
@@ -4110,11 +4110,11 @@ static void usage(void)
 #endif
                        break;
                case 'U':
-                       pstrcpy(username,optarg);
+                       fstrcpy(username,optarg);
                        p = strchr_m(username,'%');
                        if (p) {
                                *p = 0;
-                               pstrcpy(password, p+1);
+                               fstrcpy(password, p+1);
                                gotpass = 1;
                        }
                        break;
@@ -4128,7 +4128,7 @@ static void usage(void)
        while (!gotpass) {
                p = getpass("Password:");
                if (p) {
-                       pstrcpy(password, p);
+                       fstrcpy(password, p);
                        gotpass = 1;
                }
        }
index 017efc60ae5768c9396404e39e1f13fb2e57e9e7..7e0ed4a2030287d5176de9d57e3c69c35e5d6962 100644 (file)
@@ -210,7 +210,7 @@ int main(int argc,char *argv[])
 {
   int opt;
   unsigned int lookup_type = 0x0;
-  pstring lookup;
+  fstring lookup;
   extern int optind;
   extern char *optarg;
   BOOL find_master=False;
index e41edcf6f8a42c9138b2fac7448a1b6883eaf86b..a5cee0dae1202593a9069cf138ffd0e3747bb578 100644 (file)
@@ -718,7 +718,7 @@ static struct cli_state *connect_one(const char *share)
        if (!got_pass) {
                char *pass = getpass("Password: ");
                if (pass) {
-                       pstrcpy(password, pass);
+                       fstrcpy(password, pass);
                        got_pass = True;
                }
        }
@@ -806,7 +806,7 @@ You can string acls together with spaces, commas or newlines\n\
 
                if ((p=strchr_m(username,'%'))) {
                        *p = 0;
-                       pstrcpy(password,p+1);
+                       fstrcpy(password,p+1);
                        got_pass = True;
                        memset(strchr_m(getenv("USER"), '%') + 1, 'X',
                               strlen(password));
@@ -820,7 +820,7 @@ You can string acls together with spaces, commas or newlines\n\
                        p = strchr_m(username,'%');
                        if (p) {
                                *p = 0;
-                               pstrcpy(password, p+1);
+                               fstrcpy(password, p+1);
                                got_pass = 1;
                        }
                        break;