From: Gary Lockyer Date: Wed, 15 Apr 2026 00:35:24 +0000 (+1200) Subject: s3:utils:clirap2 fix tautological-compare X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=3287641bbf3360c8241db090781ebc2d5febbc96;p=thirdparty%2Fsamba.git s3:utils:clirap2 fix tautological-compare 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 Reviewed-by: Stefan Metzmacher Reviewed-by: Volker Lendecke --- diff --git a/source3/utils/clirap2.c b/source3/utils/clirap2.c index 61f46980fff..d8ef486f6bd 100644 --- a/source3/utils/clirap2.c +++ b/source3/utils/clirap2.c @@ -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 {