From c2b867038a9e4ddad987bbc6472bd9b8d42fed9d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 22 May 2002 11:25:43 +0000 Subject: Fix a silly memory (getpnam_alloc()) leak spotted by Elrond, and move the DATA_BLOB code into its own file. It would be nice to go over some of the other util.c functions, and check that we still use them all, and that we use them in more than one place. Andrew Bartlett (This used to be commit d0ea70fce55df9a5b5878f50fce7bc115ffb37c2) --- source3/lib/data_blob.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 source3/lib/data_blob.c (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c new file mode 100644 index 0000000000..6b9f5cbb04 --- /dev/null +++ b/source3/lib/data_blob.c @@ -0,0 +1,109 @@ +/* + Unix SMB/CIFS implementation. + Easy management of byte-length data + Copyright (C) Andrew Tridgell 2001 + Copyright (C) Andrew Bartlett 2001 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/******************************************************************* + free() a data blob +*******************************************************************/ +static void free_data_blob(DATA_BLOB *d) +{ + if ((d) && (d->free)) { + SAFE_FREE(d->data); + } +} + +/******************************************************************* + 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 (!length) { + ZERO_STRUCT(ret); + return ret; + } + + if (p) { + ret.data = smb_xmemdup(p, length); + } else { + ret.data = smb_xmalloc(length); + } + ret.length = length; + ret.free = free_data_blob; + return ret; +} + +/******************************************************************* + construct a data blob, using supplied TALLOC_CTX +*******************************************************************/ +DATA_BLOB data_blob_talloc(TALLOC_CTX *mem_ctx, const void *p, size_t length) +{ + DATA_BLOB ret; + + if (!p || !length) { + ZERO_STRUCT(ret); + return ret; + } + + ret.data = talloc_memdup(mem_ctx, p, length); + if (ret.data == NULL) + smb_panic("data_blob_talloc: talloc_memdup failed.\n"); + + ret.length = length; + ret.free = NULL; + return ret; +} + +/******************************************************************* +free a data blob +*******************************************************************/ +void data_blob_free(DATA_BLOB *d) +{ + if (d) { + if (d->free) { + (d->free)(d); + } + ZERO_STRUCTP(d); + } +} + +/******************************************************************* +clear a DATA_BLOB's contents +*******************************************************************/ +void data_blob_clear(DATA_BLOB *d) +{ + if (d->data) { + memset(d->data, 0, d->length); + } +} + +/******************************************************************* +free a data blob and clear its contents +*******************************************************************/ +void data_blob_clear_free(DATA_BLOB *d) +{ + data_blob_clear(d); + data_blob_free(d); +} + -- cgit From fb70dbdffa865b453330911841ce920ab19ad60c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 23 May 2002 14:24:59 +0000 Subject: Nobody uses this, and its really just a layer of internal implementation. Make it static (till sombody needs its...) (This used to be commit 89dc15732062b46276d1d7a155954ee565070491) --- source3/lib/data_blob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index 6b9f5cbb04..d690cd05a0 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -91,7 +91,7 @@ void data_blob_free(DATA_BLOB *d) /******************************************************************* clear a DATA_BLOB's contents *******************************************************************/ -void data_blob_clear(DATA_BLOB *d) +static void data_blob_clear(DATA_BLOB *d) { if (d->data) { memset(d->data, 0, d->length); -- cgit From f504cc4e10006f324bef9f3149d4099fba6ea732 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Jan 2003 23:15:14 +0000 Subject: Don't touch data after a free. Jeremy. (This used to be commit 3aea32c8e6d204e41776b4bce79234d2159867b3) --- source3/lib/data_blob.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index d690cd05a0..250c3ade88 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -84,7 +84,6 @@ void data_blob_free(DATA_BLOB *d) if (d->free) { (d->free)(d); } - ZERO_STRUCTP(d); } } -- cgit From d1221c9b6c369113a531063737890b58d89bf6fe Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 24 Feb 2003 02:55:00 +0000 Subject: Merge from HEAD client-side authentication changes: - new kerberos code, allowing the account to change it's own password without special SD settings required - NTLMSSP client code, now seperated from cliconnect.c - NTLMv2 client code - SMB signing fixes Andrew Bartlett (This used to be commit 837680ca517982f2e5944730581a83012d4181ae) --- source3/lib/data_blob.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index 250c3ade88..4056212fc5 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -84,6 +84,7 @@ void data_blob_free(DATA_BLOB *d) if (d->free) { (d->free)(d); } + d->length = 0; } } -- cgit From fcbfc7ad0669009957c65fa61bb20df75a9701b4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 22 Nov 2003 13:19:38 +0000 Subject: Changes all over the shop, but all towards: - NTLM2 support in the server - KEY_EXCH support in the server - variable length session keys. In detail: - NTLM2 is an extension of NTLMv1, that is compatible with existing domain controllers (unlike NTLMv2, which requires a DC upgrade). * This is known as 'NTLMv2 session security' * (This is not yet implemented on the RPC pipes however, so there may well still be issues for PDC setups, particuarly around password changes. We do not fully understand the sign/seal implications of NTLM2 on RPC pipes.) This requires modifications to our authentication subsystem, as we must handle the 'challege' input into the challenge-response algorithm being changed. This also needs to be turned off for 'security=server', which does not support this. - KEY_EXCH is another 'security' mechanism, whereby the session key actually used by the server is sent by the client, rather than being the shared-secret directly or indirectly. - As both these methods change the session key, the auth subsystem needed to be changed, to 'override' session keys provided by the backend. - There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation. - The 'names blob' in NTLMSSP is always in unicode - never in ascii. Don't make an ascii version ever. - The other big change is to allow variable length session keys. We have always assumed that session keys are 16 bytes long - and padded to this length if shorter. However, Kerberos session keys are 8 bytes long, when the krb5 login uses DES. * This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. * - Add better DEBUG() messages to ntlm_auth, warning administrators of misconfigurations that prevent access to the privileged pipe. This should help reduce some of the 'it just doesn't work' issues. - Fix data_blob_talloc() to behave the same way data_blob() does when passed a NULL data pointer. (just allocate) REMEMBER to make clean after this commit - I have changed plenty of data structures... (This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc) --- source3/lib/data_blob.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index 4056212fc5..83afc591a1 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -61,14 +61,20 @@ DATA_BLOB data_blob_talloc(TALLOC_CTX *mem_ctx, const void *p, size_t length) { DATA_BLOB ret; - if (!p || !length) { + if (!length) { ZERO_STRUCT(ret); return ret; } - ret.data = talloc_memdup(mem_ctx, p, length); - if (ret.data == NULL) - smb_panic("data_blob_talloc: talloc_memdup failed.\n"); + if (p) { + ret.data = talloc_memdup(mem_ctx, p, length); + if (ret.data == NULL) + smb_panic("data_blob_talloc: talloc_memdup failed.\n"); + } else { + ret.data = talloc(mem_ctx, length); + if (ret.data == NULL) + smb_panic("data_blob_talloc: talloc failed.\n"); + } ret.length = length; ret.free = NULL; -- cgit From acf9d61421faa6c0055d57fdee7db300dc5431aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Dec 2004 18:25:53 +0000 Subject: r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a) --- source3/lib/data_blob.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index 83afc591a1..a1c3af2d49 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -47,7 +47,7 @@ DATA_BLOB data_blob(const void *p, size_t length) if (p) { ret.data = smb_xmemdup(p, length); } else { - ret.data = smb_xmalloc(length); + ret.data = SMB_XMALLOC_ARRAY(char, length); } ret.length = length; ret.free = free_data_blob; @@ -67,11 +67,11 @@ DATA_BLOB data_blob_talloc(TALLOC_CTX *mem_ctx, const void *p, size_t length) } if (p) { - ret.data = talloc_memdup(mem_ctx, p, length); + ret.data = TALLOC_MEMDUP(mem_ctx, p, length); if (ret.data == NULL) smb_panic("data_blob_talloc: talloc_memdup failed.\n"); } else { - ret.data = talloc(mem_ctx, length); + ret.data = TALLOC(mem_ctx, length); if (ret.data == NULL) smb_panic("data_blob_talloc: talloc failed.\n"); } -- cgit From 0fcb427f78cbce93be85720656c767f545cd84ff Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 19 Mar 2005 20:49:09 +0000 Subject: r5907: Fix compile warning noticed by Jason Mader . Bug #2483. Jeremy. (This used to be commit f6db0f5e8aaa8cfc65031d19a231f7a5a68796a7) --- source3/lib/data_blob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index a1c3af2d49..35805f861c 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -47,7 +47,7 @@ DATA_BLOB data_blob(const void *p, size_t length) if (p) { ret.data = smb_xmemdup(p, length); } else { - ret.data = SMB_XMALLOC_ARRAY(char, length); + ret.data = SMB_XMALLOC_ARRAY(unsigned char, length); } ret.length = length; ret.free = free_data_blob; -- cgit From 19ca97a70f6b7b41d251eaa76e4d3c980c6eedff Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 24 Jun 2005 20:25:18 +0000 Subject: r7882: Looks like a large patch - but what it actually does is make Samba safe for using our headers and linking with C++ modules. Stops us from using C++ reserved keywords in our code. Jeremy (This used to be commit 9506b8e145982b1160a2f0aee5c9b7a54980940a) --- source3/lib/data_blob.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index 35805f861c..161f46a941 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -35,6 +35,7 @@ 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; -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/lib/data_blob.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index 161f46a941..ccd0d27f47 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -22,8 +22,9 @@ #include "includes.h" /******************************************************************* - free() a data blob + Free() a data blob. *******************************************************************/ + static void free_data_blob(DATA_BLOB *d) { if ((d) && (d->free)) { @@ -32,8 +33,8 @@ 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 + 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) @@ -56,8 +57,9 @@ DATA_BLOB data_blob(const void *p, size_t length) } /******************************************************************* - construct a data blob, using supplied TALLOC_CTX + Construct a data blob, using supplied TALLOC_CTX. *******************************************************************/ + DATA_BLOB data_blob_talloc(TALLOC_CTX *mem_ctx, const void *p, size_t length) { DATA_BLOB ret; @@ -83,8 +85,9 @@ DATA_BLOB data_blob_talloc(TALLOC_CTX *mem_ctx, const void *p, size_t length) } /******************************************************************* -free a data blob + Free a data blob. *******************************************************************/ + void data_blob_free(DATA_BLOB *d) { if (d) { @@ -96,8 +99,9 @@ void data_blob_free(DATA_BLOB *d) } /******************************************************************* -clear a DATA_BLOB's contents + Clear a DATA_BLOB's contents *******************************************************************/ + static void data_blob_clear(DATA_BLOB *d) { if (d->data) { @@ -106,11 +110,11 @@ static void data_blob_clear(DATA_BLOB *d) } /******************************************************************* -free a data blob and clear its contents + Free a data blob and clear its contents *******************************************************************/ + void data_blob_clear_free(DATA_BLOB *d) { data_blob_clear(d); data_blob_free(d); } - -- cgit From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/lib/data_blob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index ccd0d27f47..860ef5ad10 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -102,7 +102,7 @@ void data_blob_free(DATA_BLOB *d) Clear a DATA_BLOB's contents *******************************************************************/ -static void data_blob_clear(DATA_BLOB *d) +void data_blob_clear(DATA_BLOB *d) { if (d->data) { memset(d->data, 0, d->length); -- cgit From e23781b3b304d1e69ad80af5ae9c0ed8d02cf996 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 30 Jul 2006 16:36:56 +0000 Subject: r17316: More C++ warnings -- 456 left (This used to be commit 1e4ee728df7eeafc1b4d533240acb032f73b4f5c) --- source3/lib/data_blob.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index 860ef5ad10..4d5dda2435 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -47,9 +47,9 @@ DATA_BLOB data_blob(const void *p, size_t length) } if (p) { - ret.data = smb_xmemdup(p, length); + ret.data = (uint8 *)smb_xmemdup(p, length); } else { - ret.data = SMB_XMALLOC_ARRAY(unsigned char, length); + ret.data = SMB_XMALLOC_ARRAY(uint8, length); } ret.length = length; ret.free = free_data_blob; @@ -70,11 +70,11 @@ DATA_BLOB data_blob_talloc(TALLOC_CTX *mem_ctx, const void *p, size_t length) } if (p) { - ret.data = TALLOC_MEMDUP(mem_ctx, p, length); + ret.data = (uint8 *)TALLOC_MEMDUP(mem_ctx, p, length); if (ret.data == NULL) smb_panic("data_blob_talloc: talloc_memdup failed.\n"); } else { - ret.data = TALLOC(mem_ctx, length); + ret.data = (uint8 *)TALLOC(mem_ctx, length); if (ret.data == NULL) smb_panic("data_blob_talloc: talloc failed.\n"); } -- cgit From 2fb8589862506d8a325f85c6c7d67509fe149d48 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 20 Sep 2006 07:15:42 +0000 Subject: r18709: add some useful function from samba4 metze (This used to be commit f7a93b6acb705256c2aa4fe6475b89223af30491) --- source3/lib/data_blob.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index 4d5dda2435..c7eadc1acf 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -118,3 +118,28 @@ void data_blob_clear_free(DATA_BLOB *d) data_blob_clear(d); data_blob_free(d); } + +/** + useful for constructing data blobs in test suites, while + avoiding const warnings +**/ +DATA_BLOB data_blob_string_const(const char *str) +{ + DATA_BLOB blob; + blob.data = CONST_DISCARD(uint8 *, str); + blob.length = strlen(str); + blob.free = NULL; + return blob; +} + +/** + * Create a new data blob from const data + */ +DATA_BLOB data_blob_const(const void *p, size_t length) +{ + DATA_BLOB blob; + blob.data = CONST_DISCARD(uint8 *, p); + blob.length = length; + blob.free = NULL; + return blob; +} -- cgit From 12ba88574bf91bdcc4447bfc3d429b799064bfd9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Apr 2007 23:18:41 +0000 Subject: r22542: Move over to using the _strict varients of the talloc calls. No functional changes. Looks bigger than it is :-). Jeremy. (This used to be commit f6fa3080fee1b20df9f1968500840a88cf0ee592) --- source3/lib/data_blob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index c7eadc1acf..e07247bc49 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -72,7 +72,7 @@ DATA_BLOB data_blob_talloc(TALLOC_CTX *mem_ctx, const void *p, size_t length) if (p) { ret.data = (uint8 *)TALLOC_MEMDUP(mem_ctx, p, length); if (ret.data == NULL) - smb_panic("data_blob_talloc: talloc_memdup failed.\n"); + smb_panic("data_blob_talloc: TALLOC_MEMDUP failed.\n"); } else { ret.data = (uint8 *)TALLOC(mem_ctx, length); if (ret.data == NULL) -- cgit From b4a7b7a8889737e2891fc1176feabd4ce47f2737 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 14 May 2007 12:16:20 +0000 Subject: r22844: Introduce const DATA_BLOB data_blob_null = { NULL, 0, NULL }; and replace all data_blob(NULL, 0) calls. (This used to be commit 3d3d61687ef00181f4f04e001d42181d93ac931e) --- source3/lib/data_blob.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index e07247bc49..6ed48888a8 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -21,6 +21,8 @@ #include "includes.h" +const DATA_BLOB data_blob_null = { NULL, 0, NULL }; + /******************************************************************* Free() a data blob. *******************************************************************/ -- cgit From b1ce226af8b61ad7e3c37860a59c6715012e738b Mon Sep 17 00:00:00 2001 From: James Peach Date: Fri, 15 Jun 2007 21:58:49 +0000 Subject: r23510: Tidy calls to smb_panic by removing trailing newlines. Print the failed expression in SMB_ASSERT. (This used to be commit 171dc060e2a576d724eed1ca65636bdafffd7713) --- source3/lib/data_blob.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index 6ed48888a8..ebe97230e4 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -74,11 +74,11 @@ DATA_BLOB data_blob_talloc(TALLOC_CTX *mem_ctx, const void *p, size_t length) if (p) { ret.data = (uint8 *)TALLOC_MEMDUP(mem_ctx, p, length); if (ret.data == NULL) - smb_panic("data_blob_talloc: TALLOC_MEMDUP failed.\n"); + smb_panic("data_blob_talloc: TALLOC_MEMDUP failed"); } else { ret.data = (uint8 *)TALLOC(mem_ctx, length); if (ret.data == NULL) - smb_panic("data_blob_talloc: talloc failed.\n"); + smb_panic("data_blob_talloc: TALLOC failed"); } ret.length = length; -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/lib/data_blob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index ebe97230e4..bd937904e2 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -6,7 +6,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/lib/data_blob.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index bd937904e2..e64e6a19a1 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -15,8 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 0565bc733566462bace3bf9dd17a6fe6cbe87db5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Dec 2007 15:16:25 +0100 Subject: Make data_blob_string_const return null terminated strings ... nobody was using it, so we're free to change it now :-) (This used to be commit 4b06c68482247d859ec30b8b1920706e43358989) --- source3/lib/data_blob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index e64e6a19a1..8bbbc32d7b 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -128,7 +128,7 @@ DATA_BLOB data_blob_string_const(const char *str) { DATA_BLOB blob; blob.data = CONST_DISCARD(uint8 *, str); - blob.length = strlen(str); + blob.length = strlen(str) + 1; blob.free = NULL; return blob; } -- cgit From 0622fd72a341889fead15a50369f7ed39cc66edc Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 10:19:06 +0100 Subject: Merge data_blob_talloc_zero() from samba4. Guenther (This used to be commit 9fca3ca37eaf10c24f852e854dd28b7155c3e536) --- source3/lib/data_blob.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index 8bbbc32d7b..daba17df14 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -144,3 +144,15 @@ DATA_BLOB data_blob_const(const void *p, size_t length) blob.free = NULL; return blob; } + +/** + construct a zero data blob, using supplied TALLOC_CTX. + use this sparingly as it initialises data - better to initialise + yourself if you want specific data in the blob +**/ +DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length) +{ + DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, length); + data_blob_clear(&blob); + return blob; +} -- cgit From ad73cb11a2a650ece09e3989f5b019234d9517ff Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 25 Apr 2008 20:06:19 +0200 Subject: Merge data_blob_hex_string from Samba4. Guenther (This used to be commit 686d8939d90eab958d3a352fe53917ba7a17f39a) --- source3/lib/data_blob.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source3/lib/data_blob.c') diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index daba17df14..66c5daf363 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -156,3 +156,25 @@ DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length) data_blob_clear(&blob); return blob; } + +/** +print the data_blob as hex string +**/ +_PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob) +{ + int i; + char *hex_string; + + hex_string = talloc_array(mem_ctx, char, (blob->length*2)+1); + if (!hex_string) { + return NULL; + } + + for (i = 0; i < blob->length; i++) + slprintf(&hex_string[i*2], 3, "%02X", blob->data[i]); + + hex_string[(blob->length*2)] = '\0'; + return hex_string; +} + + -- cgit