r12758: r12127@cabra: derrell | 2006-01-03 15:22:18 -0500
[idra/samba.git] / source3 / libsmb / clilist.c
index a0be40bdc9f5128241a0ef2e59ed3c22120d433b..48780e28dfa9637a870cb8dfd9e61363e13fdf39 100644 (file)
@@ -49,9 +49,9 @@ static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,f
                case 1: /* OS/2 understands this */
                        /* these dates are converted to GMT by
                            make_unix_date */
-                       finfo->ctime = make_unix_date2(p+4);
-                       finfo->atime = make_unix_date2(p+8);
-                       finfo->mtime = make_unix_date2(p+12);
+                       finfo->ctime = cli_make_unix_date2(cli, p+4);
+                       finfo->atime = cli_make_unix_date2(cli, p+8);
+                       finfo->mtime = cli_make_unix_date2(cli, p+12);
                        finfo->size = IVAL(p,16);
                        finfo->mode = CVAL(p,24);
                        len = CVAL(p, 26);
@@ -70,9 +70,9 @@ static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,f
                case 2: /* this is what OS/2 uses mostly */
                        /* these dates are converted to GMT by
                            make_unix_date */
-                       finfo->ctime = make_unix_date2(p+4);
-                       finfo->atime = make_unix_date2(p+8);
-                       finfo->mtime = make_unix_date2(p+12);
+                       finfo->ctime = cli_make_unix_date2(cli, p+4);
+                       finfo->atime = cli_make_unix_date2(cli, p+8);
+                       finfo->mtime = cli_make_unix_date2(cli, p+12);
                        finfo->size = IVAL(p,16);
                        finfo->mode = CVAL(p,24);
                        len = CVAL(p, 30);
@@ -169,11 +169,7 @@ static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,f
 int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, 
                 void (*fn)(const char *, file_info *, const char *, void *), void *state)
 {
-#if 1
-       int max_matches = 1366; /* Match W2k - was 512. */
-#else
-       int max_matches = 512;
-#endif
+        int max_matches = 1366;
        int info_level;
        char *p, *p2;
        pstring mask;
@@ -271,6 +267,10 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
                           it gives ERRSRV/ERRerror temprarily */
                        uint8 eclass;
                        uint32 ecode;
+
+                       SAFE_FREE(rdata);
+                       SAFE_FREE(rparam);
+
                        cli_dos_error(cli, &eclass, &ecode);
                        if (eclass != ERRSRV || ecode != ERRerror)
                                break;
@@ -278,8 +278,11 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
                        continue;
                }
 
-                if (cli_is_error(cli) || !rdata || !rparam) 
+                if (cli_is_error(cli) || !rdata || !rparam) {
+                       SAFE_FREE(rdata);
+                       SAFE_FREE(rparam);
                        break;
+               }
 
                if (total_received == -1)
                        total_received = 0;
@@ -297,8 +300,11 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
                        ff_lastname = SVAL(p,6);
                }
 
-               if (ff_searchcount == 0) 
+               if (ff_searchcount == 0) {
+                       SAFE_FREE(rdata);
+                       SAFE_FREE(rparam);
                        break;
+               }
 
                /* point to the data bytes */
                p = rdata;
@@ -332,6 +338,8 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
 
                if (!tdl) {
                        DEBUG(0,("cli_list_new: Failed to expand dirlist\n"));
+                       SAFE_FREE(rdata);
+                       SAFE_FREE(rparam);
                        break;
                } else {
                        dirlist = tdl;
@@ -380,7 +388,7 @@ static int interpret_short_filename(struct cli_state *cli, char *p,file_info *fi
        finfo->mode = CVAL(p,21);
        
        /* this date is converted to GMT by make_unix_date */
-       finfo->ctime = make_unix_date(p+22);
+       finfo->ctime = cli_make_unix_date(cli, p+22);
        finfo->mtime = finfo->atime = finfo->ctime;
        finfo->size = IVAL(p,26);
        clistr_pull(cli, finfo->name, p+30, sizeof(finfo->name), 12, STR_ASCII);