Use samr connect4, then fall back to samr connect if it fails. This is
[kai/samba.git] / source3 / libsmb / clilist.c
index a99bc91bfb5b6a4e64e616b8fe05fd8721d0a53b..17a759f9e39371455fdb39ea116e64425eddbfbb 100644 (file)
@@ -1,6 +1,5 @@
 /* 
-   Unix SMB/Netbios implementation.
-   Version 3.0
+   Unix SMB/CIFS implementation.
    client directory list routines
    Copyright (C) Andrew Tridgell 1994-1998
    
@@ -55,10 +54,14 @@ static int interpret_long_filename(struct cli_state *cli,
                        len = CVAL(p, 26);
                        p += 27;
                        p += clistr_align_in(cli, p, 0);
+                       /* the len+2 below looks strange but it is
+                          important to cope with the differences
+                          between win2000 and win9x for this call
+                          (tridge) */
                        p += clistr_pull(cli, finfo->name, p,
-                                   sizeof(finfo->name),
-                                   len
-                                   STR_TERMINATE);
+                                        sizeof(finfo->name),
+                                        len+2
+                                        STR_TERMINATE);
                        return PTR_DIFF(p, base);
 
                case 2: /* this is what OS/2 uses mostly */
@@ -283,9 +286,9 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
 
                total_received += ff_searchcount;
 
-               if (rdata) free(rdata); rdata = NULL;
-               if (rparam) free(rparam); rparam = NULL;
-               
+               SAFE_FREE(rdata);
+               SAFE_FREE(rparam);
+
                DEBUG(3,("received %d entries (eos=%d)\n",
                         ff_searchcount,ff_eos));
 
@@ -300,7 +303,7 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
        }
 
        /* free up the dirlist buffer */
-       if (dirlist) free(dirlist);
+       SAFE_FREE(dirlist);
        return(total_received);
 }
 
@@ -358,7 +361,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
 
                set_message(cli->outbuf,2,0,True);
 
-               CVAL(cli->outbuf,smb_com) = SMBsearch;
+               SCVAL(cli->outbuf,smb_com,SMBsearch);
 
                SSVAL(cli->outbuf,smb_tid,cli->cnum);
                cli_setup_packet(cli);
@@ -394,7 +397,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
 
                if (!tdl) {
                        DEBUG(0,("cli_list_old: failed to expand dirlist"));
-                       if (dirlist) free(dirlist);
+                       SAFE_FREE(dirlist);
                        return 0;
                }
                else dirlist = tdl;
@@ -416,7 +419,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
                memset(cli->inbuf,'\0',smb_size);
 
                set_message(cli->outbuf,2,0,True);
-               CVAL(cli->outbuf,smb_com) = SMBfclose;
+               SCVAL(cli->outbuf,smb_com,SMBfclose);
                SSVAL(cli->outbuf,smb_tid,cli->cnum);
                cli_setup_packet(cli);
 
@@ -446,7 +449,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
                fn(&finfo, Mask, state);
        }
 
-       if (dirlist) free(dirlist);
+       SAFE_FREE(dirlist);
        return(num_received);
 }