diff --git a/selftest/knownfail.d/bad-write b/selftest/knownfail.d/bad-write deleted file mode 100644 index 5fc16606a13..00000000000 --- a/selftest/knownfail.d/bad-write +++ /dev/null @@ -1,2 +0,0 @@ -^samba3.raw.write.bad-write\(nt4_dc_smb1\) -^samba3.raw.write.bad-write\(ad_dc_smb1\) diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 344a997cbd2..c75b93fcc25 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -152,7 +152,7 @@ /* the remaining number of bytes in smb buffer 'buf' from pointer 'p'. */ #define smb_bufrem(buf, p) (smb_buflen(buf)-PTR_DIFF(p, smb_buf(buf))) -#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. */ diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index d4573d3da55..e1a47a65662 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -345,7 +345,7 @@ size_t srvstr_get_path_req(TALLOC_CTX *mem_ctx, struct smb_request *req, { ssize_t bufrem = smbreq_bufrem(req, src); - if (bufrem < 0) { + if (bufrem == 0) { *err = NT_STATUS_INVALID_PARAMETER; return 0; } @@ -383,7 +383,7 @@ size_t srvstr_pull_req_talloc(TALLOC_CTX *ctx, struct smb_request *req, { ssize_t bufrem = smbreq_bufrem(req, src); - if (bufrem < 0) { + if (bufrem == 0) { return 0; }