mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
s3: Simplify smb_splice_chain
We use it in smbd/process.c only now. This only splices in finished buffers, both callers used the same arguments. Pull that into the routine itself.
This commit is contained in:
parent
947a8bc44a
commit
da322e4f3f
@ -1775,22 +1775,18 @@ static bool find_andx_cmd_ofs(uint8_t *buf, size_t *pofs)
|
|||||||
/**
|
/**
|
||||||
* @brief Do the smb chaining at a buffer level
|
* @brief Do the smb chaining at a buffer level
|
||||||
* @param[in] poutbuf Pointer to the talloc'ed buffer to be modified
|
* @param[in] poutbuf Pointer to the talloc'ed buffer to be modified
|
||||||
* @param[in] smb_command The command that we want to issue
|
* @param[in] andx_buf Buffer to be appended
|
||||||
* @param[in] wct How many words?
|
|
||||||
* @param[in] vwv The words, already in network order
|
|
||||||
* @param[in] bytes_alignment How shall we align "bytes"?
|
|
||||||
* @param[in] num_bytes How many bytes?
|
|
||||||
* @param[in] bytes The data the request ships
|
|
||||||
*
|
|
||||||
* smb_splice_chain() adds the vwv and bytes to the request already present in
|
|
||||||
* *poutbuf.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static bool smb_splice_chain(uint8_t **poutbuf, uint8_t smb_command,
|
static bool smb_splice_chain(uint8_t **poutbuf, const uint8_t *andx_buf)
|
||||||
uint8_t wct, const uint16_t *vwv,
|
|
||||||
size_t bytes_alignment,
|
|
||||||
uint32_t num_bytes, const uint8_t *bytes)
|
|
||||||
{
|
{
|
||||||
|
uint8_t smb_command = CVAL(andx_buf, smb_com);
|
||||||
|
uint8_t wct = CVAL(andx_buf, smb_wct);
|
||||||
|
const uint16_t *vwv = (const uint16_t *)(andx_buf + smb_vwv);
|
||||||
|
size_t bytes_alignment = 0;
|
||||||
|
uint32_t num_bytes = smb_buflen(andx_buf);
|
||||||
|
const uint8_t *bytes = (const uint8_t *)smb_buf(andx_buf);
|
||||||
|
|
||||||
uint8_t *outbuf;
|
uint8_t *outbuf;
|
||||||
size_t old_size, new_size;
|
size_t old_size, new_size;
|
||||||
size_t ofs;
|
size_t ofs;
|
||||||
@ -1983,12 +1979,7 @@ void chain_reply(struct smb_request *req)
|
|||||||
SSVAL(req->chain_outbuf, smb_tid, SVAL(req->outbuf, smb_tid));
|
SSVAL(req->chain_outbuf, smb_tid, SVAL(req->outbuf, smb_tid));
|
||||||
SSVAL(req->chain_outbuf, smb_uid, SVAL(req->outbuf, smb_uid));
|
SSVAL(req->chain_outbuf, smb_uid, SVAL(req->outbuf, smb_uid));
|
||||||
|
|
||||||
if (!smb_splice_chain(&req->chain_outbuf,
|
if (!smb_splice_chain(&req->chain_outbuf, req->outbuf)) {
|
||||||
CVAL(req->outbuf, smb_com),
|
|
||||||
CVAL(req->outbuf, smb_wct),
|
|
||||||
(uint16_t *)(req->outbuf + smb_vwv),
|
|
||||||
0, smb_buflen(req->outbuf),
|
|
||||||
(uint8_t *)smb_buf(req->outbuf))) {
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
TALLOC_FREE(req->outbuf);
|
TALLOC_FREE(req->outbuf);
|
||||||
@ -2144,12 +2135,7 @@ void chain_reply(struct smb_request *req)
|
|||||||
SSVAL(req->chain_outbuf, smb_rcls, SVAL(req->outbuf, smb_rcls));
|
SSVAL(req->chain_outbuf, smb_rcls, SVAL(req->outbuf, smb_rcls));
|
||||||
SSVAL(req->chain_outbuf, smb_err, SVAL(req->outbuf, smb_err));
|
SSVAL(req->chain_outbuf, smb_err, SVAL(req->outbuf, smb_err));
|
||||||
|
|
||||||
if (!smb_splice_chain(&req->chain_outbuf,
|
if (!smb_splice_chain(&req->chain_outbuf, req->outbuf)) {
|
||||||
CVAL(req->outbuf, smb_com),
|
|
||||||
CVAL(req->outbuf, smb_wct),
|
|
||||||
(uint16_t *)(req->outbuf + smb_vwv),
|
|
||||||
0, smb_buflen(req->outbuf),
|
|
||||||
(uint8_t *)smb_buf(req->outbuf))) {
|
|
||||||
exit_server_cleanly("chain_reply: smb_splice_chain failed\n");
|
exit_server_cleanly("chain_reply: smb_splice_chain failed\n");
|
||||||
}
|
}
|
||||||
TALLOC_FREE(req->outbuf);
|
TALLOC_FREE(req->outbuf);
|
||||||
|
Loading…
Reference in New Issue
Block a user