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>
#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)
{
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;