mirror of
https://github.com/samba-team/samba.git
synced 2025-01-14 19:24:43 +03:00
fix smb_len calculation for chained requests
I think chain_reply() is one of the most tricky parts of Samba. This recursion needs to go away, we need to sequentially walk the chain list.
This commit is contained in:
parent
0ff16e8573
commit
af2b01d851
@ -1653,6 +1653,7 @@ void chain_reply(struct smb_request *req)
|
|||||||
char *outbuf = (char *)req->outbuf;
|
char *outbuf = (char *)req->outbuf;
|
||||||
size_t outsize = smb_len(outbuf) + 4;
|
size_t outsize = smb_len(outbuf) + 4;
|
||||||
size_t outsize_padded;
|
size_t outsize_padded;
|
||||||
|
size_t padding;
|
||||||
size_t ofs, to_move;
|
size_t ofs, to_move;
|
||||||
|
|
||||||
struct smb_request *req2;
|
struct smb_request *req2;
|
||||||
@ -1691,6 +1692,7 @@ void chain_reply(struct smb_request *req)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
outsize_padded = (outsize + 3) & ~3;
|
outsize_padded = (outsize + 3) & ~3;
|
||||||
|
padding = outsize_padded - outsize;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* remember how much the caller added to the chain, only counting
|
* remember how much the caller added to the chain, only counting
|
||||||
@ -1804,17 +1806,17 @@ void chain_reply(struct smb_request *req)
|
|||||||
SCVAL(outbuf, smb_vwv0, smb_com2);
|
SCVAL(outbuf, smb_vwv0, smb_com2);
|
||||||
SSVAL(outbuf, smb_vwv1, chain_size + smb_wct - 4);
|
SSVAL(outbuf, smb_vwv1, chain_size + smb_wct - 4);
|
||||||
|
|
||||||
if (outsize_padded > outsize) {
|
if (padding != 0) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Due to padding we have some uninitialized bytes after the
|
* Due to padding we have some uninitialized bytes after the
|
||||||
* caller's output
|
* caller's output
|
||||||
*/
|
*/
|
||||||
|
|
||||||
memset(outbuf + outsize, 0, outsize_padded - outsize);
|
memset(outbuf + outsize, 0, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
smb_setlen(outbuf, outsize2 + chain_size - 4);
|
smb_setlen(outbuf, outsize2 + caller_outputlen + padding - 4);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* restore the saved data, being careful not to overwrite any data
|
* restore the saved data, being careful not to overwrite any data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user