diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-10-26 14:20:53 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2011-10-26 15:33:30 +0200 |
commit | 5f520e771786d416d55c8d0a84e411c73fc5396c (patch) | |
tree | 5d26c55b96218ebaf81a987983911d7a867dc5ed /libcli | |
parent | d66d7c2b00ad2ca97562c133f2e7701cae971e48 (diff) | |
download | samba-5f520e771786d416d55c8d0a84e411c73fc5396c.tar.gz samba-5f520e771786d416d55c8d0a84e411c73fc5396c.tar.bz2 samba-5f520e771786d416d55c8d0a84e411c73fc5396c.zip |
libcli/smb: add smb_buffer_oob() helper
A copy of trans_oob().
metze
Diffstat (limited to 'libcli')
-rw-r--r-- | libcli/smb/smb_util.h | 2 | ||||
-rw-r--r-- | libcli/smb/util.c | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/libcli/smb/smb_util.h b/libcli/smb/smb_util.h index b5a06524cb..322ecb6397 100644 --- a/libcli/smb/smb_util.h +++ b/libcli/smb/smb_util.h @@ -23,3 +23,5 @@ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib); uint32_t unix_perms_to_wire(mode_t perms); mode_t wire_perms_to_unix(uint32_t perms); mode_t unix_filetype_from_wire(uint32_t wire_type); + +bool smb_buffer_oob(uint32_t bufsize, uint32_t offset, uint32_t length); diff --git a/libcli/smb/util.c b/libcli/smb/util.c index b8c3dc5e96..b02ae00d0d 100644 --- a/libcli/smb/util.c +++ b/libcli/smb/util.c @@ -163,3 +163,15 @@ mode_t unix_filetype_from_wire(uint32_t wire_type) } } +bool smb_buffer_oob(uint32_t bufsize, uint32_t offset, uint32_t length) +{ + if ((offset + length < offset) || (offset + length < length)) { + /* wrap */ + return true; + } + if ((offset > bufsize) || (offset + length > bufsize)) { + /* overflow */ + return true; + } + return false; +} |