summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/util/util.h2
-rw-r--r--lib/util/util_str.c4
-rw-r--r--source4/dsdb/samdb/ldb_modules/extended_dn.c4
-rw-r--r--source4/dsdb/samdb/ldb_modules/password_hash.c6
-rw-r--r--source4/dsdb/schema/schema_init.c6
-rw-r--r--source4/dsdb/schema/schema_set.c3
-rw-r--r--source4/kdc/hdb-samba4.c3
-rw-r--r--source4/lib/registry/util.c3
-rw-r--r--source4/librpc/ndr/ndr_drsuapi.c5
-rw-r--r--source4/torture/auth/ntlmssp.c12
-rw-r--r--source4/torture/ndr/ndr.c4
-rw-r--r--source4/utils/ntlm_auth.c6
12 files changed, 25 insertions, 33 deletions
diff --git a/lib/util/util.h b/lib/util/util.h
index 47adf067f0..38b59862fc 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -241,7 +241,7 @@ _PUBLIC_ size_t strhex_to_str(char *p, size_t len, const char *strhex);
/**
* Parse a hex string and return a data blob.
*/
-_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(const char *strhex) ;
+_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *strhex) ;
/**
* Routine to print a buffer as HEX digits, into an allocated string.
diff --git a/lib/util/util_str.c b/lib/util/util_str.c
index 9ea6403c52..389b289bfb 100644
--- a/lib/util/util_str.c
+++ b/lib/util/util_str.c
@@ -216,9 +216,9 @@ _PUBLIC_ size_t strhex_to_str(char *p, size_t len, const char *strhex)
/**
* Parse a hex string and return a data blob.
*/
-_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(const char *strhex)
+_PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *strhex)
{
- DATA_BLOB ret_blob = data_blob(NULL, strlen(strhex)/2+1);
+ DATA_BLOB ret_blob = data_blob(mem_ctx, strlen(strhex)/2+1);
ret_blob.length = strhex_to_str((char *)ret_blob.data,
strlen(strhex),
diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn.c b/source4/dsdb/samdb/ldb_modules/extended_dn.c
index 88a8887056..a0602d9281 100644
--- a/source4/dsdb/samdb/ldb_modules/extended_dn.c
+++ b/source4/dsdb/samdb/ldb_modules/extended_dn.c
@@ -424,7 +424,7 @@ static int extended_search(struct ldb_module *module, struct ldb_request *req)
valstr = str;
} else {
DATA_BLOB binary;
- binary = strhex_to_data_blob(str);
+ binary = strhex_to_data_blob(NULL, str);
if (!binary.data) {
ldb_oom(module->ldb);
return LDB_ERR_OPERATIONS_ERROR;
@@ -471,7 +471,7 @@ static int extended_search(struct ldb_module *module, struct ldb_request *req)
valstr = str;
} else {
DATA_BLOB binary;
- binary = strhex_to_data_blob(str);
+ binary = strhex_to_data_blob(NULL, str);
if (!binary.data) {
ldb_oom(module->ldb);
return LDB_ERR_OPERATIONS_ERROR;
diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c
index c4451d1355..5ed7f1fbad 100644
--- a/source4/dsdb/samdb/ldb_modules/password_hash.c
+++ b/source4/dsdb/samdb/ldb_modules/password_hash.c
@@ -482,12 +482,11 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io,
if (old_scp) {
DATA_BLOB blob;
- blob = strhex_to_data_blob(old_scp->data);
+ blob = strhex_to_data_blob(io->ac, old_scp->data);
if (!blob.data) {
ldb_oom(io->ac->module->ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- talloc_steal(io->ac, blob.data);
/* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */
ndr_err = ndr_pull_struct_blob(&blob, io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), &_old_pkb,
@@ -596,12 +595,11 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io,
if (old_scp) {
DATA_BLOB blob;
- blob = strhex_to_data_blob(old_scp->data);
+ blob = strhex_to_data_blob(io->ac, old_scp->data);
if (!blob.data) {
ldb_oom(io->ac->module->ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- talloc_steal(io->ac, blob.data);
/* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */
ndr_err = ndr_pull_struct_blob(&blob, io->ac,
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 93697a3df0..69d4c2ce80 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -199,9 +199,8 @@ WERROR dsdb_get_oid_mappings_ldb(const struct dsdb_schema *schema,
return ntstatus_to_werror(nt_status);
}
- *schemaInfo = strhex_to_data_blob(schema->schema_info);
+ *schemaInfo = strhex_to_data_blob(mem_ctx, schema->schema_info);
W_ERROR_HAVE_NO_MEMORY(schemaInfo->data);
- talloc_steal(mem_ctx, schemaInfo->data);
return WERR_OK;
}
@@ -819,12 +818,11 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
}
info_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "schemaInfo");
if (!info_val) {
- info_val_default = strhex_to_data_blob("FF0000000000000000000000000000000000000000");
+ info_val_default = strhex_to_data_blob(mem_ctx, "FF0000000000000000000000000000000000000000");
if (!info_val_default.data) {
dsdb_oom(error_string, mem_ctx);
return LDB_ERR_OPERATIONS_ERROR;
}
- talloc_steal(mem_ctx, info_val_default.data);
info_val = &info_val_default;
}
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index f8de82e56a..d0aae4e221 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -328,11 +328,10 @@ WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf
info_val = ldb_msg_find_ldb_val(msg, "schemaInfo");
if (!info_val) {
- info_val_default = strhex_to_data_blob("FF0000000000000000000000000000000000000000");
+ info_val_default = strhex_to_data_blob(mem_ctx, "FF0000000000000000000000000000000000000000");
if (!info_val_default.data) {
goto nomem;
}
- talloc_steal(mem_ctx, info_val_default.data);
info_val = &info_val_default;
}
diff --git a/source4/kdc/hdb-samba4.c b/source4/kdc/hdb-samba4.c
index 3a1379bee4..b6a48e79d0 100644
--- a/source4/kdc/hdb-samba4.c
+++ b/source4/kdc/hdb-samba4.c
@@ -277,12 +277,11 @@ static krb5_error_code LDB_message2entry_keys(krb5_context context,
if (scpk) {
DATA_BLOB blob;
- blob = strhex_to_data_blob(scpk->data);
+ blob = strhex_to_data_blob(mem_ctx, scpk->data);
if (!blob.data) {
ret = ENOMEM;
goto out;
}
- talloc_steal(mem_ctx, blob.data);
/* we cannot use ndr_pull_struct_blob_all() here, as w2k and w2k3 add padding bytes */
ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, iconv_convenience, &_pkb,
diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c
index 68efd56a86..b3b6e49ea5 100644
--- a/source4/lib/registry/util.c
+++ b/source4/lib/registry/util.c
@@ -140,8 +140,7 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx,
break;
case REG_BINARY:
- *data = strhex_to_data_blob(data_str);
- talloc_steal(mem_ctx, data->data);
+ *data = strhex_to_data_blob(mem_ctx, data_str);
break;
default:
diff --git a/source4/librpc/ndr/ndr_drsuapi.c b/source4/librpc/ndr/ndr_drsuapi.c
index cb022d2ad3..064b50a9cd 100644
--- a/source4/librpc/ndr/ndr_drsuapi.c
+++ b/source4/librpc/ndr/ndr_drsuapi.c
@@ -92,7 +92,7 @@ enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_fl
DATA_BLOB blob;
if (strncasecmp("ff", r->oid, 2) == 0) {
- blob = strhex_to_data_blob(r->oid);
+ blob = strhex_to_data_blob(ndr, r->oid);
if (!blob.data) {
return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT,
"HEX String Conversion Error: %s\n",
@@ -101,7 +101,6 @@ enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_fl
} else {
_OID_PUSH_CHECK(ber_write_OID_String(&blob, r->oid));
}
- talloc_steal(ndr, blob.data);
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, blob.length));
NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, blob.data, blob.length));
@@ -165,7 +164,7 @@ size_t ndr_size_drsuapi_DsReplicaOID_oid(const char *oid, int flags)
if (!oid) return 0;
if (strncasecmp("ff", oid, 2) == 0) {
- _blob = strhex_to_data_blob(oid);
+ _blob = strhex_to_data_blob(NULL, oid);
if (_blob.data) {
ret = _blob.length;
}
diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c
index 739a048d29..1e8b339997 100644
--- a/source4/torture/auth/ntlmssp.c
+++ b/source4/torture/auth/ntlmssp.c
@@ -48,7 +48,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
- gensec_ntlmssp_state->session_key = strhex_to_data_blob("0102030405060708090a0b0c0d0e0f00");
+ gensec_ntlmssp_state->session_key = strhex_to_data_blob(tctx, "0102030405060708090a0b0c0d0e0f00");
dump_data_pw("NTLMSSP session key: \n",
gensec_ntlmssp_state->session_key.data,
gensec_ntlmssp_state->session_key.length);
@@ -59,11 +59,11 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
ntlmssp_sign_init(gensec_ntlmssp_state),
"Failed to sign_init");
- data = strhex_to_data_blob("6a43494653");
+ data = strhex_to_data_blob(tctx, "6a43494653");
gensec_ntlmssp_sign_packet(gensec_security, gensec_security,
data.data, data.length, data.data, data.length, &sig);
- expected_sig = strhex_to_data_blob("01000000e37f97f2544f4d7e00000000");
+ expected_sig = strhex_to_data_blob(tctx, "01000000e37f97f2544f4d7e00000000");
dump_data_pw("NTLMSSP calc sig: ", sig.data, sig.length);
dump_data_pw("NTLMSSP expected sig: ", expected_sig.data, expected_sig.length);
@@ -103,7 +103,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
- gensec_ntlmssp_state->session_key = strhex_to_data_blob("0102030405e538b0");
+ gensec_ntlmssp_state->session_key = strhex_to_data_blob(tctx, "0102030405e538b0");
dump_data_pw("NTLMSSP session key: \n",
gensec_ntlmssp_state->session_key.data,
gensec_ntlmssp_state->session_key.length);
@@ -114,11 +114,11 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
ntlmssp_sign_init(gensec_ntlmssp_state),
"Failed to sign_init");
- data = strhex_to_data_blob("6a43494653");
+ data = strhex_to_data_blob(tctx, "6a43494653");
gensec_ntlmssp_sign_packet(gensec_security, gensec_security,
data.data, data.length, data.data, data.length, &sig);
- expected_sig = strhex_to_data_blob("0100000078010900397420fe0e5a0f89");
+ expected_sig = strhex_to_data_blob(tctx, "0100000078010900397420fe0e5a0f89");
dump_data_pw("NTLMSSP calc sig: ", sig.data, sig.length);
dump_data_pw("NTLMSSP expected sig: ", expected_sig.data, expected_sig.length);
diff --git a/source4/torture/ndr/ndr.c b/source4/torture/ndr/ndr.c
index 8d4d43b2a0..70bd070009 100644
--- a/source4/torture/ndr/ndr.c
+++ b/source4/torture/ndr/ndr.c
@@ -96,7 +96,7 @@ static bool test_check_string_terminator(struct torture_context *tctx)
TALLOC_CTX *mem_ctx = tctx;
/* Simple test */
- blob = strhex_to_data_blob("0000");
+ blob = strhex_to_data_blob(tctx, "0000");
ndr = ndr_pull_init_blob(&blob, mem_ctx, lp_iconv_convenience(tctx->lp_ctx));
@@ -115,7 +115,7 @@ static bool test_check_string_terminator(struct torture_context *tctx)
talloc_free(ndr);
- blob = strhex_to_data_blob("11220000");
+ blob = strhex_to_data_blob(tctx, "11220000");
ndr = ndr_pull_init_blob(&blob, mem_ctx, lp_iconv_convenience(tctx->lp_ctx));
torture_assert_ndr_success(tctx,
diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c
index 6a6302837e..1ec87c6b42 100644
--- a/source4/utils/ntlm_auth.c
+++ b/source4/utils/ntlm_auth.c
@@ -869,7 +869,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod
}
if (strequal(request, "LANMAN-Challenge")) {
- challenge = strhex_to_data_blob(parameter);
+ challenge = strhex_to_data_blob(NULL, parameter);
if (challenge.length != 8) {
mux_printf(mux_id, "Error: hex decode of %s failed! (got %d bytes, expected 8)\n.\n",
parameter,
@@ -877,7 +877,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod
challenge = data_blob(NULL, 0);
}
} else if (strequal(request, "NT-Response")) {
- nt_response = strhex_to_data_blob(parameter);
+ nt_response = strhex_to_data_blob(NULL, parameter);
if (nt_response.length < 24) {
mux_printf(mux_id, "Error: hex decode of %s failed! (only got %d bytes, needed at least 24)\n.\n",
parameter,
@@ -885,7 +885,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod
nt_response = data_blob(NULL, 0);
}
} else if (strequal(request, "LANMAN-Response")) {
- lm_response = strhex_to_data_blob(parameter);
+ lm_response = strhex_to_data_blob(NULL, parameter);
if (lm_response.length != 24) {
mux_printf(mux_id, "Error: hex decode of %s failed! (got %d bytes, expected 24)\n.\n",
parameter,