Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/smbd/smb2_find.c

    r414 r745  
    2020
    2121#include "includes.h"
     22#include "smbd/smbd.h"
    2223#include "smbd/globals.h"
    2324#include "../libcli/smb/smb_common.h"
     25#include "trans2.h"
     26#include "../lib/util/tevent_ntstatus.h"
    2427
    2528static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX *mem_ctx,
     
    9093        }
    9194
     95        /* The output header is 8 bytes. */
     96        if (in_output_buffer_length <= 8) {
     97                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
     98        }
     99
     100        DEBUG(10,("smbd_smb2_request_find_done: in_output_buffer_length = %u\n",
     101                (unsigned int)in_output_buffer_length ));
     102
     103        /* Take into account the output header. */
     104        in_output_buffer_length -= 8;
     105
    92106        in_file_name_buffer.data = (uint8_t *)req->in.vector[i+2].iov_base;
    93107        in_file_name_buffer.length = in_file_name_length;
     
    104118        if (req->compat_chain_fsp) {
    105119                /* skip check */
    106         } else if (in_file_id_persistent != 0) {
     120        } else if (in_file_id_persistent != in_file_id_volatile) {
    107121                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
    108122        }
     
    172186        SIVAL(outbody.data, 0x04,
    173187              out_output_buffer.length);        /* output buffer length */
     188
     189        DEBUG(10,("smbd_smb2_request_find_done: out_output_buffer.length = %u\n",
     190                (unsigned int)out_output_buffer.length ));
    174191
    175192        outdyn = out_output_buffer;
     
    211228        char *end_data;
    212229        int last_entry_off = 0;
    213         uint64_t off = 0;
     230        int off = 0;
    214231        uint32_t num = 0;
    215         uint32_t dirtype = aHIDDEN | aSYSTEM | aDIR;
    216         const char *directory;
     232        uint32_t dirtype = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY;
    217233        bool dont_descend = false;
    218234        bool ask_sharemode = true;
     
    253269        }
    254270
    255         directory = fsp->fsp_name->base_name;
    256 
    257271        if (strcmp(in_file_name, "") == 0) {
    258272                tevent_req_nterror(req, NT_STATUS_OBJECT_NAME_INVALID);
     
    304318
    305319        if (in_flags & SMB2_CONTINUE_FLAG_REOPEN) {
    306                 if (fsp->dptr) {
    307                         dptr_CloseDir(fsp->dptr);
    308                         fsp->dptr = NULL;
    309                 }
     320                dptr_CloseDir(fsp);
    310321        }
    311322
     
    321332
    322333                status = dptr_create(conn,
    323                                      directory,
     334                                     fsp,
     335                                     fsp->fsp_name->base_name,
    324336                                     false, /* old_handle */
    325337                                     false, /* expect_close */
     
    360372        pdata = (char *)state->out_output_buffer.data;
    361373        base_data = pdata;
    362         end_data = pdata + in_output_buffer_length;
     374        /*
     375         * end_data must include the safety margin as it's what is
     376         * used to determine if pushed strings have been truncated.
     377         */
     378        end_data = pdata + in_output_buffer_length + DIR_ENTRY_SAFETY_MARGIN - 1;
    363379        last_entry_off = 0;
    364380        off = 0;
    365381        num = 0;
    366382
    367         DEBUG(8,("smbd_smb2_find_send: dirpath=<%s> dontdescend=<%s>\n",
    368                 directory, lp_dontdescend(SNUM(conn))));
    369         if (in_list(directory,lp_dontdescend(SNUM(conn)),conn->case_sensitive)) {
     383        DEBUG(8,("smbd_smb2_find_send: dirpath=<%s> dontdescend=<%s>, "
     384                "in_output_buffer_length = %u\n",
     385                fsp->fsp_name->base_name, lp_dontdescend(SNUM(conn)),
     386                (unsigned int)in_output_buffer_length ));
     387        if (in_list(fsp->fsp_name->base_name,lp_dontdescend(SNUM(conn)),
     388                        conn->case_sensitive)) {
    370389                dont_descend = true;
    371390        }
     
    380399                bool out_of_space = false;
    381400                int space_remaining = in_output_buffer_length - off;
     401
     402                SMB_ASSERT(space_remaining >= 0);
    382403
    383404                ok = smbd_dirptr_lanman2_entry(state,
     
    402423                                               NULL);
    403424
    404                 off = PTR_DIFF(pdata, base_data);
     425                off = (int)PTR_DIFF(pdata, base_data);
    405426
    406427                if (!ok) {
Note: See TracChangeset for help on using the changeset viewer.