]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:utils:clirap2 fix tautological-compare
authorGary Lockyer <gary@catalyst.net.nz>
Wed, 15 Apr 2026 00:35:24 +0000 (12:35 +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/utils/clirap2.c

index 61f46980fff5f01ab5c4aa6ca89ef01ef2fa1661..d8ef486f6bd47c5d88983d1da94ce60f904956af 100644 (file)
@@ -82,6 +82,7 @@
 #include "../librpc/gen_ndr/svcctl.h"
 #include "clirap2.h"
 #include "../libcli/smb/smbXcli_base.h"
+#include "lib/util/overflow.h"
 
 #define WORDSIZE 2
 #define DWORDSIZE 4
@@ -212,7 +213,7 @@ static size_t rap_getstringp(TALLOC_CTX *ctx, char *p, char **dest, char *r, uin
                off &= 0x0000FFFF; /* mask the obsolete segment number from the offset */
                off -= c;
        }
-       if (r+off > endp || r+off < r) {
+       if (offset_outside_range(r, endp, off)) {
                src="";
                len=1;
        } else {