diff options
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 5d583f25c3..25b60dc9ef 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -587,6 +587,27 @@ int set_message_end(const char *frombuf, void *outbuf,void *end_ptr) } /******************************************************************* + Add a data blob to the end of a smb_buf, adjusting bcc and smb_len. + Return the bytes added +********************************************************************/ + +ssize_t message_push_blob(uint8 **outbuf, DATA_BLOB blob) +{ + size_t newlen = smb_len(*outbuf) + 4 + blob.length; + uint8 *tmp; + + if (!(tmp = TALLOC_REALLOC_ARRAY(NULL, *outbuf, uint8, newlen))) { + DEBUG(0, ("talloc failed\n")); + return -1; + } + *outbuf = tmp; + + memcpy(tmp + smb_len(tmp) + 4, blob.data, blob.length); + set_message_bcc(NULL, (char *)tmp, smb_buflen(tmp) + blob.length); + return blob.length; +} + +/******************************************************************* Reduce a file name, removing .. elements. ********************************************************************/ |