]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/torture/test_smb1_dfs fix tautological-compare
authorGary Lockyer <gary@catalyst.net.nz>
Wed, 15 Apr 2026 00:33:08 +0000 (12:33 +1200)
committerStefan Metzmacher <metze@samba.org>
Thu, 28 May 2026 17:39:48 +0000 (17:39 +0000)
The wrapping of pointer arithmetic is undefined behaviour. Clang from version 20
onwards will treat an overflow check of the following form:
   ptr + offset < ptr
as always evaluating to false.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=16092

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/torture/test_smb1_dfs.c

index 42ef340dc1c6c06efc05db8f6a4dc9dcb7f6feda..2bf5e03dc196c46c49129e768f46639c98cead2e 100644 (file)
@@ -32,6 +32,7 @@
 #include "async_smb.h"
 #include "../lib/util/tevent_ntstatus.h"
 #include "lib/util/time_basic.h"
+#include "lib/util/overflow.h"
 
 extern fstring host, workgroup, share, password, username, myname;
 extern struct cli_credentials *torture_creds;
@@ -1949,8 +1950,8 @@ static size_t calc_next_entry_offset(const uint8_t *base,
        size_t next_entry_offset = (size_t)PULL_LE_U32(base,0);
 
        if (next_entry_offset == 0 ||
-                       base + next_entry_offset < base ||
-                       base + next_entry_offset > pdata_end) {
+           offset_outside_range(base, pdata_end, next_entry_offset))
+       {
                next_entry_offset = pdata_end - base;
        }
        return next_entry_offset;
@@ -2009,7 +2010,7 @@ static size_t get_filename(TALLOC_CTX *ctx,
                return pdata_end - base;
        }
        p += 24; /* short name */
-       if (p + namelen < p || p + namelen > pdata_end) {
+       if (offset_outside_range(p, pdata_end, namelen)) {
                return pdata_end - base;
        }
        ret = pull_string_talloc(ctx,