diff options
author | Stefan Metzmacher <metze@samba.org> | 2005-11-16 11:01:15 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:46:20 -0500 |
commit | e9eb56068573d89f8ce45f08220ca870b3daa669 (patch) | |
tree | 49e99d6c86f3e921c6b6a06570a6d7799f5064f7 /source4/libcli/smb2/smb2.h | |
parent | 43fa1b6dbd5e03251572fb6c2ee7c7f59f413c7d (diff) | |
download | samba-e9eb56068573d89f8ce45f08220ca870b3daa669.tar.gz samba-e9eb56068573d89f8ce45f08220ca870b3daa669.tar.bz2 samba-e9eb56068573d89f8ce45f08220ca870b3daa669.zip |
r11741: - the buffer code (first 2 bytes in the SMB2 body) seem to be the length
of the fixed body part, and +1 if there's a dynamic part
- there're 3 types of dynamic blobs
with uint16_t offset/uint16_t size
with uint16_t offset/uint32_t size
with uint32_t offset/uint32_t size /* aligned to 8 bytes */
- strings are transmitted in UTF-16 with no termination and
packet into a uint16/uint16 blob
metze
(This used to be commit 79103c51e5c752fbdb4d25a0047b65002828df89)
Diffstat (limited to 'source4/libcli/smb2/smb2.h')
-rw-r--r-- | source4/libcli/smb2/smb2.h | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index e99e8d3945..47dd6fd272 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -87,13 +87,11 @@ struct smb2_request_buffer { /* the packet body */ uint8_t *body; uint_t body_size; - - /* ptr is used as a moving pointer into the data area - * of the packet. The reason its here and not a local - * variable in each function is that when a realloc of - * a send packet is done we need to move this - * pointer */ - uint8_t *ptr; + + /* this point to the next dynamic byte that can be used + * this will be moved when some dynamic data is pushed + */ + uint8_t *dynamic; }; @@ -176,13 +174,20 @@ struct smb2_request { #define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */ /* - check that a buffer code matches the expected value + check that a body has the expected size */ -#define SMB2_CHECK_BUFFER_CODE(req, code) do { \ - io->out.buffer_code = SVAL(req->in.body, 0); \ - if (io->out.buffer_code != (code)) { \ - DEBUG(0,("Unexpected buffer code 0x%x. Expected 0x%x\n", \ - io->out.buffer_code, code)); \ +#define SMB2_CHECK_PACKET_RECV(req, size, dynamic) do { \ + uint_t is_size = req->in.body_size; \ + uint16_t field_size = SVAL(req->in.body, 0); \ + uint16_t want_size = ((dynamic)?(size)+1:(size)); \ + if (is_size < (size)) { \ + DEBUG(0,("%s: buffer too small 0x%x. Expected 0x%x\n", \ + __location__, is_size, want_size)); \ + return NT_STATUS_BUFFER_TOO_SMALL; \ + }\ + if (field_size != want_size) { \ + DEBUG(0,("%s: unexpected fixed body size 0x%x. Expected 0x%x\n", \ + __location__, field_size, want_size)); \ return NT_STATUS_INVALID_PARAMETER; \ } \ } while (0) |