mirror of
https://github.com/samba-team/samba.git
synced 2025-07-29 15:42:04 +03:00
Convert SMB and SMB2 code to use a common buffer handling structure
This converts our SMB and SMB2 code to use a common structure "struct
request_bufinfo" for information on the buffer bounds of a packet,
alignment information and string handling. This allows us to use a
common backend for SMB and SMB2 code, while still using all the same
string and blob handling functions.
Up to now we had been passing a NULL req handle into these common
routines from the SMB2 side of the server, which meant that we failed
any operation which did a bounds checked string extraction (such as a
RenameInformation setinfo call, which is what Vista uses for renaming
files)
There is still some more work to be done on this - for example we can
now remove many of the SMB2 specific buffer handling functions that we
had, and use the SMB ones.
(This used to be commit ca6d9be6cb
)
This commit is contained in:
@ -78,7 +78,7 @@ NTSTATUS smbsrv_blob_fill_data(TALLOC_CTX *mem_ctx,
|
||||
/*
|
||||
pull a string from a blob in a trans2 request
|
||||
*/
|
||||
size_t smbsrv_blob_pull_string(struct smbsrv_request *req,
|
||||
size_t smbsrv_blob_pull_string(struct request_bufinfo *bufinfo,
|
||||
const DATA_BLOB *blob,
|
||||
uint16_t offset,
|
||||
const char **str,
|
||||
@ -92,7 +92,7 @@ size_t smbsrv_blob_pull_string(struct smbsrv_request *req,
|
||||
return 0;
|
||||
}
|
||||
|
||||
return req_pull_string(req, str,
|
||||
return req_pull_string(bufinfo, str,
|
||||
blob->data + offset,
|
||||
blob->length - offset,
|
||||
STR_NO_RANGE_CHECK | flags);
|
||||
@ -521,7 +521,7 @@ NTSTATUS smbsrv_pull_passthru_sfileinfo(TALLOC_CTX *mem_ctx,
|
||||
union smb_setfileinfo *st,
|
||||
const DATA_BLOB *blob,
|
||||
int default_str_flags,
|
||||
struct smbsrv_request *req)
|
||||
struct request_bufinfo *bufinfo)
|
||||
{
|
||||
uint32_t len;
|
||||
DATA_BLOB str_blob;
|
||||
@ -560,12 +560,8 @@ NTSTATUS smbsrv_pull_passthru_sfileinfo(TALLOC_CTX *mem_ctx,
|
||||
return NT_STATUS_OK;
|
||||
|
||||
case RAW_SFILEINFO_RENAME_INFORMATION:
|
||||
if (!req) {
|
||||
/*
|
||||
* TODO: get rid of smbsrv_request argument of
|
||||
* smbsrv_blob_pull_string()
|
||||
*/
|
||||
return NT_STATUS_NOT_IMPLEMENTED;
|
||||
if (!bufinfo) {
|
||||
return NT_STATUS_INTERNAL_ERROR;
|
||||
}
|
||||
BLOB_CHECK_MIN_SIZE(blob, 12);
|
||||
|
||||
@ -574,7 +570,7 @@ NTSTATUS smbsrv_pull_passthru_sfileinfo(TALLOC_CTX *mem_ctx,
|
||||
len = IVAL(blob->data, 8);
|
||||
str_blob.data = blob->data+12;
|
||||
str_blob.length = MIN(blob->length, len);
|
||||
smbsrv_blob_pull_string(req, &str_blob, 0,
|
||||
smbsrv_blob_pull_string(bufinfo, &str_blob, 0,
|
||||
&st->rename_information.in.new_name,
|
||||
STR_UNICODE);
|
||||
if (st->rename_information.in.new_name == NULL) {
|
||||
|
Reference in New Issue
Block a user