1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-26 18:50:30 +03:00

libcli/smb: add smb_buffer_oob() helper

A copy of trans_oob().

metze
This commit is contained in:
Stefan Metzmacher 2011-10-26 14:20:53 +02:00
parent d66d7c2b00
commit 5f520e7717
2 changed files with 14 additions and 0 deletions

View File

@ -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);

View File

@ -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;
}