s3:locking: Fix integer overflow check in posix_lock_in_range()
authorAndreas Schneider <asn@samba.org>
Thu, 7 Dec 2017 17:24:18 +0000 (18:24 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 20 Mar 2018 22:16:16 +0000 (23:16 +0100)
This fixes compilation with -Wstrict-overflow=2

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/locking/posix.c

index ff794282114af0186121f2d50c933495ec3fb51f..0b627aaa3e58ed2190a143e3bd028653ad97115c 100644 (file)
@@ -145,7 +145,8 @@ static bool posix_lock_in_range(off_t *offset_out, off_t *count_out,
         * Truncate count to end at max lock offset.
         */
 
-       if (offset + count < 0 || offset + count > max_positive_lock_offset) {
+       if (offset > INT64_MAX - count ||
+           offset + count > max_positive_lock_offset) {
                count = max_positive_lock_offset - offset;
        }