]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:libsmb:cliquota fix tautological-compare
authorGary Lockyer <gary@catalyst.net.nz>
Wed, 15 Apr 2026 01:32:11 +0000 (13:32 +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/libsmb/cliquota.c

index 0f38c2757922266273fb75b9271c531a0f9601d9..5a2a1b4028c5d4cb50032e376b29bb581a37751b 100644 (file)
@@ -27,6 +27,7 @@
 #include "trans2.h"
 #include "../libcli/smb/smbXcli_base.h"
 #include "librpc/gen_ndr/ndr_quota.h"
+#include "lib/util/overflow.h"
 
 NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum)
 {
@@ -136,7 +137,7 @@ NTSTATUS parse_user_quota_list(const uint8_t *curdata,
                        break;
                }
 
-               if (curdata + offset < curdata) {
+               if (ptr_overflow(curdata, offset, uint8_t)) {
                        DEBUG(1, ("Pointer overflow in quota record\n"));
                        status = NT_STATUS_INVALID_NETWORK_RESPONSE;
                        break;