s3:libsmb: add trans2_bytes_push_bytes()
authorStefan Metzmacher <metze@samba.org>
Thu, 7 Jul 2011 08:02:36 +0000 (10:02 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 7 Jul 2011 12:45:12 +0000 (14:45 +0200)
metze

source3/libsmb/clifile.c
source3/libsmb/proto.h

index 9bb83ec9c6e6fdfc4de32b74a265c4cfc04da08e..3fa124e6f1c39175a1b1b9ad8d04a4a1c967fc06 100644 (file)
@@ -136,6 +136,25 @@ uint8_t *trans2_bytes_push_str(uint8_t *buf, bool ucs2,
                        false, pconverted_size);
 }
 
+uint8_t *trans2_bytes_push_bytes(uint8_t *buf,
+                                const uint8_t *bytes, size_t num_bytes)
+{
+       size_t buflen;
+
+       if (buf == NULL) {
+               return NULL;
+       }
+       buflen = talloc_get_size(buf);
+
+       buf = talloc_realloc(NULL, buf, uint8_t,
+                            buflen + num_bytes);
+       if (buf == NULL) {
+               return NULL;
+       }
+       memcpy(&buf[buflen], bytes, num_bytes);
+       return buf;
+}
+
 struct cli_setpathinfo_state {
        uint16_t setup;
        uint8_t *param;
index 9783b0d0e83eb34905d63eee018d3d7bbebec165..ac0e031a62409c69172bd1833c25563b5a0847d9 100644 (file)
@@ -357,6 +357,8 @@ uint8_t *smb_bytes_push_bytes(uint8_t *buf, uint8_t prefix,
 uint8_t *trans2_bytes_push_str(uint8_t *buf, bool ucs2,
                               const char *str, size_t str_len,
                               size_t *pconverted_size);
+uint8_t *trans2_bytes_push_bytes(uint8_t *buf,
+                                const uint8_t *bytes, size_t num_bytes);
 struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
                                   struct event_context *ev,
                                   struct cli_state *cli, const char *fname,