r21949: After discussion with the Apple and Linux client maintainers,
authorJames Peach <jpeach@samba.org>
Fri, 23 Mar 2007 19:24:21 +0000 (19:24 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:49:39 +0000 (14:49 -0500)
changing the FindFirst response for the UNIX_INFO2 level to include
a length field before the name. The name is not required to be null
terminated. the lenght field does not count any null.

source/libcli/raw/interfaces.h
source/libcli/raw/rawsearch.c
source/torture/unix/unix_info2.c

index e4efab3375085848981e82c89940bcf99987d5bb..4620baed789514bfdd36d0f896e7a1003a32c186 100644 (file)
@@ -2576,7 +2576,7 @@ union smb_search_data {
                NTTIME create_time;
                uint32_t file_flags;
                uint32_t flags_mask;
-               const char *name;
+               struct smb_wire_string name;
        } unix_info2;
 };
 
index 5abe19d50c40399e118376e3f2cbb4c9d8b78b71..3c7ca5788e0a96312253831d246bf81b37ce9b7e 100644 (file)
@@ -607,7 +607,12 @@ static int parse_trans2_search(struct smbcli_tree *tree,
                return ofs;
 
        case RAW_SEARCH_DATA_UNIX_INFO2:
-               if (blob->length < (116 + 8 + 1)) {
+               /*   8 - size of ofs + file_index
+                * 116 - size of unix_info2
+                *   4 - size of name length
+                *   2 - "." is the shortest name
+                */
+               if (blob->length < (116 + 8 + 4 + 2)) {
                        return -1;
                }
 
@@ -630,11 +635,16 @@ static int parse_trans2_search(struct smbcli_tree *tree,
                data->unix_info2.file_flags         = IVAL(blob->data, 116);
                data->unix_info2.flags_mask         = IVAL(blob->data, 120);
 
-               /* There is no length field for this name but we know it's null terminated. */
-               len = smbcli_blob_pull_unix_string(tree->session, mem_ctx, blob,
-                                          &data->unix_info2.name, 116 + 8, 0);
+               /* There is a 4 byte length field for this name. The length
+                * does not include the NULL terminator.
+                */
+               len = smbcli_blob_pull_string(tree->session, mem_ctx, blob,
+                                      &data->unix_info2.name,
+                                      8 + 116, /* offset to length */
+                                      8 + 116 + 4, /* offset to string */
+                                      0);
 
-               if (ofs != 0 && ofs < (116 + 8 + len)) {
+               if (ofs != 0 && ofs < (8 + 116 + 4 + len)) {
                        return -1;
                }
 
index 66ec96bfd966c1a22f52d375877be532059e046d..8c642c1d8df25237437a2df891e45ddd154a9519 100644 (file)
@@ -298,7 +298,7 @@ static BOOL verify_setinfo_flags(void *mem_ctx,
                if (info2.file_flags & smb_fmask) {
                        torture_assert_ntstatus_equal(torture,
                                        status, NT_STATUS_OK,
-                                       "setting UNIX_INFO2 flags");
+                                       "setting valid UNIX_INFO2 flag");
 
                        if (!query_path_info2(mem_ctx, torture, cli,
                                                fname, &info2)) {
@@ -314,7 +314,7 @@ static BOOL verify_setinfo_flags(void *mem_ctx,
                         */
                        torture_assert_ntstatus_equal(torture,
                                        status, NT_STATUS_INVALID_PARAMETER,
-                                       "setting UNIX_INFO2 flags");
+                                       "setting invalid UNIX_INFO2 flag");
                }
        }