smbd: qfilepathinfo has fixed/variable buffers
authorVolker Lendecke <vl@samba.org>
Tue, 27 Aug 2013 09:06:27 +0000 (09:06 +0000)
committerKarolin Seeger <kseeger@samba.org>
Fri, 6 Sep 2013 08:49:49 +0000 (10:49 +0200)
The error message will have to change depending whether the buffer is
too small for the fixed or variable buffers

Bug: https://bugzilla.samba.org/show_bug.cgi?id=10106
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 53123996033594f68a3fc9037474aada3aef0750)

source3/smbd/globals.h
source3/smbd/smb2_getinfo.c
source3/smbd/trans2.c

index ce5b18dbf9ca1b97628366739be752a218ee9f1e..7fbe608744076e6f87aed6e9eed59baa3935117d 100644 (file)
@@ -162,6 +162,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                               char *lock_data,
                               uint16_t flags2,
                               unsigned int max_data_bytes,
+                              size_t *fixed_portion,
                               char **ppdata,
                               unsigned int *pdata_size);
 
index 36b5140396c71c88b1ac9c76b93a47b5659a18ae..b9911524ff68f8def14e90bfb6adbdcfe1091567 100644 (file)
@@ -284,6 +284,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
                struct ea_list *ea_list = NULL;
                int lock_data_count = 0;
                char *lock_data = NULL;
+               size_t fixed_portion;
 
                ZERO_STRUCT(write_time_ts);
 
@@ -371,6 +372,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
                                               lock_data,
                                               STR_UNICODE,
                                               in_output_buffer_length,
+                                              &fixed_portion,
                                               &data,
                                               &data_size);
                if (!NT_STATUS_IS_OK(status)) {
index fda962c65f5d44e202bb19ce04bedca48e6590f6..f1da13eb3de18ffc2e8de51f2733096b5d4e9fd4 100644 (file)
@@ -4286,6 +4286,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                               char *lock_data,
                               uint16_t flags2,
                               unsigned int max_data_bytes,
+                              size_t *fixed_portion,
                               char **ppdata,
                               unsigned int *pdata_size)
 {
@@ -4421,6 +4422,8 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
           BasicFileInformationTest. -tpot */
        file_index = get_FileIndex(conn, psbuf);
 
+       *fixed_portion = 0;
+
        switch (info_level) {
                case SMB_INFO_STANDARD:
                        DEBUG(10,("smbd_do_qfilepathinfo: SMB_INFO_STANDARD\n"));
@@ -4558,6 +4561,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        DEBUG(5,("write: %s ", ctime(&mtime)));
                        DEBUG(5,("change: %s ", ctime(&c_time)));
                        DEBUG(5,("mode: %x\n", mode));
+                       *fixed_portion = data_size;
                        break;
 
                case SMB_FILE_STANDARD_INFORMATION:
@@ -4571,6 +4575,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        SCVAL(pdata,20,delete_pending?1:0);
                        SCVAL(pdata,21,(mode&FILE_ATTRIBUTE_DIRECTORY)?1:0);
                        SSVAL(pdata,22,0); /* Padding. */
+                       *fixed_portion = 24;
                        break;
 
                case SMB_FILE_EA_INFORMATION:
@@ -4580,6 +4585,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                            estimate_ea_size(conn, fsp, smb_fname->base_name);
                        DEBUG(10,("smbd_do_qfilepathinfo: SMB_FILE_EA_INFORMATION\n"));
                        data_size = 4;
+                       *fixed_portion = 4;
                        SIVAL(pdata,0,ea_size);
                        break;
                }
@@ -4601,6 +4607,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                                          STR_UNICODE);
                        data_size = 4 + len;
                        SIVAL(pdata,0,len);
+                       *fixed_portion = 8;
                        break;
                }
 
@@ -4664,6 +4671,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        SIVAL(pdata,0,len);
                        pdata += 4 + len;
                        data_size = PTR_DIFF(pdata,(*ppdata));
+                       *fixed_portion = 10;
                        break;
                }
 
@@ -4701,6 +4709,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        SIVAL(pdata,0,len);
                        pdata += 4 + len;
                        data_size = PTR_DIFF(pdata,(*ppdata));
+                       *fixed_portion = 104;
                        break;
                }
                case SMB_FILE_INTERNAL_INFORMATION:
@@ -4708,12 +4717,14 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        DEBUG(10,("smbd_do_qfilepathinfo: SMB_FILE_INTERNAL_INFORMATION\n"));
                        SBVAL(pdata, 0, file_index);
                        data_size = 8;
+                       *fixed_portion = 8;
                        break;
 
                case SMB_FILE_ACCESS_INFORMATION:
                        DEBUG(10,("smbd_do_qfilepathinfo: SMB_FILE_ACCESS_INFORMATION\n"));
                        SIVAL(pdata, 0, access_mask);
                        data_size = 4;
+                       *fixed_portion = 4;
                        break;
 
                case SMB_FILE_NAME_INFORMATION:
@@ -4731,24 +4742,28 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        DEBUG(10,("smbd_do_qfilepathinfo: SMB_FILE_DISPOSITION_INFORMATION\n"));
                        data_size = 1;
                        SCVAL(pdata,0,delete_pending);
+                       *fixed_portion = 1;
                        break;
 
                case SMB_FILE_POSITION_INFORMATION:
                        DEBUG(10,("smbd_do_qfilepathinfo: SMB_FILE_POSITION_INFORMATION\n"));
                        data_size = 8;
                        SOFF_T(pdata,0,pos);
+                       *fixed_portion = 8;
                        break;
 
                case SMB_FILE_MODE_INFORMATION:
                        DEBUG(10,("smbd_do_qfilepathinfo: SMB_FILE_MODE_INFORMATION\n"));
                        SIVAL(pdata,0,mode);
                        data_size = 4;
+                       *fixed_portion = 4;
                        break;
 
                case SMB_FILE_ALIGNMENT_INFORMATION:
                        DEBUG(10,("smbd_do_qfilepathinfo: SMB_FILE_ALIGNMENT_INFORMATION\n"));
                        SIVAL(pdata,0,0); /* No alignment needed. */
                        data_size = 4;
+                       *fixed_portion = 4;
                        break;
 
                /*
@@ -4793,6 +4808,8 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
 
                        TALLOC_FREE(streams);
 
+                       *fixed_portion = 32;
+
                        break;
                }
                case SMB_QUERY_COMPRESSION_INFO:
@@ -4802,6 +4819,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        SIVAL(pdata,8,0); /* ??? */
                        SIVAL(pdata,12,0); /* ??? */
                        data_size = 16;
+                       *fixed_portion = 16;
                        break;
 
                case SMB_FILE_NETWORK_OPEN_INFORMATION:
@@ -4815,6 +4833,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        SIVAL(pdata,48,mode);
                        SIVAL(pdata,52,0); /* ??? */
                        data_size = 56;
+                       *fixed_portion = 56;
                        break;
 
                case SMB_FILE_ATTRIBUTE_TAG_INFORMATION:
@@ -4822,6 +4841,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        SIVAL(pdata,0,mode);
                        SIVAL(pdata,4,0);
                        data_size = 8;
+                       *fixed_portion = 8;
                        break;
 
                /*
@@ -5091,6 +5111,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
        struct ea_list *ea_list = NULL;
        int lock_data_count = 0;
        char *lock_data = NULL;
+       size_t fixed_portion;
        NTSTATUS status = NT_STATUS_OK;
 
        if (!params) {
@@ -5452,6 +5473,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                                       ea_list,
                                       lock_data_count, lock_data,
                                       req->flags2, max_data_bytes,
+                                      &fixed_portion,
                                       ppdata, &data_size);
        if (!NT_STATUS_IS_OK(status)) {
                reply_nterror(req, status);