summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-01-05 23:30:59 +0000
committerAndrew Tridgell <tridge@samba.org>2002-01-05 23:30:59 +0000
commitb0e4827b9750edd358230890fdc671f378da9626 (patch)
tree6e05dbaff4f61076ade1a9c39cc00e92f9c26206
parentca0ccee23f9fd57982d8934e957f0c71a919614b (diff)
downloadsamba-b0e4827b9750edd358230890fdc671f378da9626.tar.gz
samba-b0e4827b9750edd358230890fdc671f378da9626.tar.bz2
samba-b0e4827b9750edd358230890fdc671f378da9626.zip
simple fix for creating blank data blobs
(This used to be commit 08bb2dfec2ca0282e9268d09da2b966d3bdf493a)
-rw-r--r--source3/lib/util.c9
-rw-r--r--source3/libsmb/clispnego.c4
2 files changed, 8 insertions, 5 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 63939e0ecf..3409124fe2 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2098,17 +2098,22 @@ static void free_data_blob(DATA_BLOB *d)
/*******************************************************************
construct a data blob, must be freed with data_blob_free()
+ you can pass NULL for p and get a blank data blob
*******************************************************************/
DATA_BLOB data_blob(const void *p, size_t length)
{
DATA_BLOB ret;
- if (!p || !length) {
+ if (!length) {
ZERO_STRUCT(ret);
return ret;
}
- ret.data = smb_xmemdup(p, length);
+ if (p) {
+ ret.data = smb_xmemdup(p, length);
+ } else {
+ ret.data = smb_xmalloc(length);
+ }
ret.length = length;
ret.free = free_data_blob;
return ret;
diff --git a/source3/libsmb/clispnego.c b/source3/libsmb/clispnego.c
index bc3873bf18..035b47b417 100644
--- a/source3/libsmb/clispnego.c
+++ b/source3/libsmb/clispnego.c
@@ -486,9 +486,7 @@ BOOL msrpc_gen(DATA_BLOB *blob,
va_end(ap);
/* allocate the space, then scan the format again to fill in the values */
- blob->data = malloc(head_size + data_size);
- blob->length = head_size + data_size;
- if (!blob->data) return False;
+ *blob = data_blob(NULL, head_size + data_size);
head_ofs = 0;
data_ofs = head_size;