lib: Simplify iov_buf
authorVolker Lendecke <vl@samba.org>
Sun, 21 Dec 2014 13:52:17 +0000 (14:52 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 9 Jan 2015 22:42:49 +0000 (23:42 +0100)
According to

https://www.securecoding.cert.org/confluence/display/seccode/INT30-C.+Ensure+that+unsigned+integer+operations+do+not+wrap

we only need to check against one operand.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Jan  9 23:42:49 CET 2015 on sn-devel-104

source3/lib/iov_buf.c

index f0e05a64dad67fe58b3703d71fc61a5f36cf2ba4..82a4af5323b86c8a92c8515c64474144953392a2 100644 (file)
@@ -39,8 +39,8 @@ ssize_t iov_buf(const struct iovec *iov, int iovcnt,
 
                tmp = needed + thislen;
 
-               if ((tmp < needed) || (tmp < thislen)) {
-                       /* overflow */
+               if (tmp < needed) {
+                       /* wrap */
                        return -1;
                }
                needed = tmp;