~ubuntu-branches/ubuntu/lucid/samba/lucid-proposed

« back to all changes in this revision

Viewing changes to debian/patches/smbclient-vfat-loop2.patch

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-07-21 17:53:23 UTC
  • mfrom: (0.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050721175323-m3oh6aoigywohfnq
Tags: 3.0.14a-6ubuntu1
Resynchronise with Debian, resolving merge conflicts (#12360)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -uNr samba-3.0.14a.orig/source/libsmb/clilist.c samba-3.0.14a/source/libsmb/clilist.c
 
2
--- samba-3.0.14a.orig/source/libsmb/clilist.c  2005-06-02 08:26:15.000000000 -0700
 
3
+++ samba-3.0.14a/source/libsmb/clilist.c       2005-06-02 08:48:04.000000000 -0700
 
4
@@ -29,8 +29,8 @@
 
5
  by NT and 2 is used by OS/2
 
6
 ****************************************************************************/
 
7
 
 
8
-static size_t interpret_long_filename(struct cli_state *cli,
 
9
-                                  int level,char *p,file_info *finfo, uint32 *p_resume_key)
 
10
+static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,file_info *finfo,
 
11
+                                     uint32 *p_resume_key, DATA_BLOB *p_last_name_raw, uint32 *p_last_name_raw_len)
 
12
 {
 
13
        extern file_info def_finfo;
 
14
        file_info finfo2;
 
15
@@ -39,7 +39,9 @@
 
16
 
 
17
        if (!finfo) finfo = &finfo2;
 
18
 
 
19
-       *p_resume_key = 0;
 
20
+       if (p_resume_key) {
 
21
+               *p_resume_key = 0;
 
22
+       }
 
23
        memcpy(finfo,&def_finfo,sizeof(*finfo));
 
24
 
 
25
        switch (level) {
 
26
@@ -86,7 +88,9 @@
 
27
                        size_t namelen, slen;
 
28
                        p += 4; /* next entry offset */
 
29
 
 
30
-                       *p_resume_key = IVAL(p,0);
 
31
+                       if (p_resume_key) {
 
32
+                               *p_resume_key = IVAL(p,0);
 
33
+                       }
 
34
                        p += 4; /* fileindex */
 
35
                                
 
36
                        /* these dates appear to arrive in a
 
37
@@ -133,6 +137,22 @@
 
38
                        clistr_pull(cli, finfo->name, p,
 
39
                                    sizeof(finfo->name),
 
40
                                    namelen, 0);
 
41
+
 
42
+                       /* To be robust in the face of unicode conversion failures
 
43
+                          we need to copy the raw bytes of the last name seen here.
 
44
+                          Namelen doesn't include the terminating unicode null, so
 
45
+                          copy it here. */
 
46
+
 
47
+                       if (p_last_name_raw && p_last_name_raw_len) {
 
48
+                               if (namelen + 2 > p_last_name_raw->length) {
 
49
+                                       memset(p_last_name_raw->data, '\0', sizeof(p_last_name_raw->length));
 
50
+                                       *p_last_name_raw_len = 0;
 
51
+                               } else {
 
52
+                                       memcpy(p_last_name_raw->data, p, namelen);
 
53
+                                       SSVAL(p_last_name_raw->data, namelen, 0);
 
54
+                                       *p_last_name_raw_len = namelen + 2;
 
55
+                               }
 
56
+                       }
 
57
                        return (size_t)IVAL(base, 0);
 
58
                }
 
59
        }
 
60
@@ -173,6 +193,8 @@
 
61
        pstring param;
 
62
        const char *mnt;
 
63
        uint32 resume_key = 0;
 
64
+       uint32 last_name_raw_len = 0;
 
65
+       DATA_BLOB last_name_raw = data_blob(NULL, 2*sizeof(pstring));
 
66
 
 
67
        /* NT uses 260, OS/2 uses 2. Both accept 1. */
 
68
        info_level = (cli->capabilities&CAP_NT_SMBS)?260:1;
 
69
@@ -214,8 +236,12 @@
 
70
                           can miss filenames. Use last filename continue instead. JRA */
 
71
                        SSVAL(param,10,(FLAG_TRANS2_FIND_REQUIRE_RESUME|FLAG_TRANS2_FIND_CLOSE_IF_END));        /* resume required + close on end */
 
72
                        p = param+12;
 
73
-                       p += clistr_push(cli, param+12, mask, sizeof(param)-12, 
 
74
-                                        STR_TERMINATE);
 
75
+                       if (last_name_raw_len && (last_name_raw_len < (sizeof(param)-12))) {
 
76
+                               memcpy(p, last_name_raw.data, last_name_raw_len);
 
77
+                               p += last_name_raw_len;
 
78
+                       } else {
 
79
+                               p += clistr_push(cli, param+12, mask, sizeof(param)-12, STR_TERMINATE);
 
80
+                       }
 
81
                }
 
82
 
 
83
                param_len = PTR_DIFF(p, param);
 
84
@@ -282,7 +308,8 @@
 
85
                                /* Last entry - fixup the last offset length. */
 
86
                                SIVAL(p2,0,PTR_DIFF((rdata + data_len),p2));
 
87
                        }
 
88
-                       p2 += interpret_long_filename(cli,info_level,p2,&finfo,&resume_key);
 
89
+                       p2 += interpret_long_filename(cli,info_level,p2,&finfo,
 
90
+                                                       &resume_key,&last_name_raw,&last_name_raw_len);
 
91
                }
 
92
 
 
93
                if (ff_lastname > 0) {
 
94
@@ -322,12 +349,13 @@
 
95
        mnt = cli_cm_get_mntpoint( cli );
 
96
 
 
97
        for (p=dirlist,i=0;i<total_received;i++) {
 
98
-               p += interpret_long_filename(cli,info_level,p,&finfo,&resume_key);
 
99
+               p += interpret_long_filename(cli,info_level,p,&finfo,NULL,NULL,NULL);
 
100
                fn( mnt,&finfo, Mask, state );
 
101
        }
 
102
 
 
103
-       /* free up the dirlist buffer */
 
104
+       /* free up the dirlist buffer and last name raw blob */
 
105
        SAFE_FREE(dirlist);
 
106
+       data_blob_free(&last_name_raw);
 
107
        return(total_received);
 
108
 }
 
109