smbd: qfsinfo 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:27 +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 ac41df91a5a425633fc716ca02187e753879d795)

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

index 95d8011bab9cec50fe3c159cc1143a5ca9234d38..c7badbc2d2ca33d84df3cf838a3359f8a09f9539 100644 (file)
@@ -156,6 +156,7 @@ NTSTATUS smbd_do_qfsinfo(connection_struct *conn,
                         uint16_t info_level,
                         uint16_t flags2,
                         unsigned int max_data_bytes,
+                        size_t *fixed_portion,
                         struct smb_filename *smb_fname,
                         char **ppdata,
                         int *ret_data_len);
index 0d75c3634419f0e6919583390f8b6c9b1a94c910..698e7752ddfa7aa62db83e4fadf70d8a363b8bae 100644 (file)
@@ -410,6 +410,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
                uint16_t file_info_level;
                char *data = NULL;
                int data_size = 0;
+               size_t fixed_portion;
 
                /* the levels directly map to the passthru levels */
                file_info_level = in_file_info_class + 1000;
@@ -418,6 +419,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
                                         file_info_level,
                                         STR_UNICODE,
                                         in_output_buffer_length,
+                                        &fixed_portion,
                                         fsp->fsp_name,
                                         &data,
                                         &data_size);
index 3916f31ca8af12fc96f69fe452da7466d8fc75ff..afd78cdb7cf038cbe51bbc8974cf7af5b3758630 100644 (file)
@@ -3117,6 +3117,7 @@ NTSTATUS smbd_do_qfsinfo(connection_struct *conn,
                         uint16_t info_level,
                         uint16_t flags2,
                         unsigned int max_data_bytes,
+                        size_t *fixed_portion,
                         struct smb_filename *fname,
                         char **ppdata,
                         int *ret_data_len)
@@ -3169,6 +3170,8 @@ NTSTATUS smbd_do_qfsinfo(connection_struct *conn,
        memset((char *)pdata,'\0',max_data_bytes + DIR_ENTRY_SAFETY_MARGIN);
        end_data = pdata + max_data_bytes + DIR_ENTRY_SAFETY_MARGIN - 1;
 
+       *fixed_portion = 0;
+
        switch (info_level) {
                case SMB_INFO_ALLOCATION:
                {
@@ -3267,6 +3270,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (u
                                data_len = max_data_bytes;
                                status = STATUS_BUFFER_OVERFLOW;
                        }
+                       *fixed_portion = 16;
                        break;
 
                case SMB_QUERY_FS_LABEL_INFO:
@@ -3303,6 +3307,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (u
                                data_len = max_data_bytes;
                                status = STATUS_BUFFER_OVERFLOW;
                        }
+                       *fixed_portion = 24;
                        break;
 
                case SMB_QUERY_FS_SIZE_INFO:
@@ -3335,6 +3340,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                        SBIG_UINT(pdata,8,dfree);
                        SIVAL(pdata,16,sectors_per_unit);
                        SIVAL(pdata,20,bytes_per_sector);
+                       *fixed_portion = 24;
                        break;
                }
 
@@ -3368,6 +3374,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                        SBIG_UINT(pdata,16,dfree); /* Actual available allocation units. */
                        SIVAL(pdata,24,sectors_per_unit); /* Sectors per allocation unit. */
                        SIVAL(pdata,28,bytes_per_sector); /* Bytes per sector. */
+                       *fixed_portion = 32;
                        break;
                }
 
@@ -3382,6 +3389,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                        data_len = 8;
                        SIVAL(pdata,0,FILE_DEVICE_DISK); /* dev type */
                        SIVAL(pdata,4,characteristics);
+                       *fixed_portion = 8;
                        break;
                }
 
@@ -3690,6 +3698,7 @@ static void call_trans2qfsinfo(connection_struct *conn,
        char *params = *pparams;
        uint16_t info_level;
        int data_len = 0;
+       size_t fixed_portion;
        NTSTATUS status;
 
        if (total_params < 2) {
@@ -3715,6 +3724,7 @@ static void call_trans2qfsinfo(connection_struct *conn,
                                 info_level,
                                 req->flags2,
                                 max_data_bytes,
+                                &fixed_portion,
                                 NULL,
                                 ppdata, &data_len);
        if (!NT_STATUS_IS_OK(status)) {