diff options
author | Volker Lendecke <vl@samba.org> | 2008-11-08 16:48:20 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-11-28 08:24:37 +0100 |
commit | 9a3be6f0f8e120797a02fa1be60b51812cfd86f5 (patch) | |
tree | d2fa5cd4e774e56a9fc000b611e5fce06da60996 /source3/lib | |
parent | 738271fc2026b2911b7d20a73496989641714df3 (diff) | |
download | samba-9a3be6f0f8e120797a02fa1be60b51812cfd86f5.tar.gz samba-9a3be6f0f8e120797a02fa1be60b51812cfd86f5.tar.bz2 samba-9a3be6f0f8e120797a02fa1be60b51812cfd86f5.zip |
Move cli_trans_oob to lib/util.c
Rename it to trans_oob, it will be used in the server routines.
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 5007fb72ef..074b523ae0 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -2879,6 +2879,25 @@ int this_is_smp(void) } /**************************************************************** + Check if offset/length fit into bufsize. Should probably be + merged with is_offset_safe, but this would require a rewrite + of lanman.c. Later :-) +****************************************************************/ + +bool trans_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; +} + +/**************************************************************** Check if an offset into a buffer is safe. If this returns True it's safe to indirect into the byte at pointer ptr+off. |