summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-02-12 23:41:48 +0100
committerVolker Lendecke <vl@samba.org>2011-02-13 12:11:53 +0100
commitf6df16d9d2913db5a0b20ac83cc512c336572877 (patch)
treeb69ccd7da33ff0940a3fbb62285f35bd5407d186 /source3
parentf49ad6d0738c34636f39df7ad0a62b9dc5b8cd4d (diff)
downloadsamba-f6df16d9d2913db5a0b20ac83cc512c336572877.tar.gz
samba-f6df16d9d2913db5a0b20ac83cc512c336572877.tar.bz2
samba-f6df16d9d2913db5a0b20ac83cc512c336572877.zip
s3: Add error checking to asn1_read_OctetString_talloc
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/tldap.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/source3/lib/tldap.c b/source3/lib/tldap.c
index 71afab9a6e..8a3da3cdbe 100644
--- a/source3/lib/tldap.c
+++ b/source3/lib/tldap.c
@@ -734,6 +734,11 @@ static void tldap_save_msg(struct tldap_context *ld, struct tevent_req *req)
static char *blob2string_talloc(TALLOC_CTX *mem_ctx, DATA_BLOB blob)
{
char *result = talloc_array(mem_ctx, char, blob.length+1);
+
+ if (result == NULL) {
+ return NULL;
+ }
+
memcpy(result, blob.data, blob.length);
result[blob.length] = '\0';
return result;
@@ -741,13 +746,21 @@ static char *blob2string_talloc(TALLOC_CTX *mem_ctx, DATA_BLOB blob)
static bool asn1_read_OctetString_talloc(TALLOC_CTX *mem_ctx,
struct asn1_data *data,
- char **result)
+ char **presult)
{
DATA_BLOB string;
+ char *result;
if (!asn1_read_OctetString(data, mem_ctx, &string))
return false;
- *result = blob2string_talloc(mem_ctx, string);
+
+ result = blob2string_talloc(mem_ctx, string);
+
data_blob_free(&string);
+
+ if (result == NULL) {
+ return false;
+ }
+ *presult = result;
return true;
}