diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 85ef221ed18..b70b029bd35 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -151,7 +151,7 @@ #define smb_buflen(buf) (SVAL(buf,smb_vwv0 + (int)CVAL(buf, smb_wct)*2)) /* the remaining number of bytes in smb buffer 'buf' from pointer 'p'. */ -#define smbreq_bufrem(req, p) (req->buflen - PTR_DIFF(p, req->buf)) +#define smbreq_bufrem(req, p) (req->buflen < PTR_DIFF(p, req->buf) ? 0 : req->buflen - PTR_DIFF(p, req->buf)) /* Note that chain_size must be available as an extern int to this macro. */