summaryrefslogtreecommitdiff
path: root/lib/util/data_blob.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-11-04 17:42:53 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-11-12 16:34:01 +1100
commitfd5174e88ca1727a91d6dc9bf9bd898ff9087fe8 (patch)
tree7f1511fcea311f2ef637ca23dee8699ba00adfb6 /lib/util/data_blob.c
parenta8769e667514f83a45ee3e825d21a351987d0210 (diff)
downloadsamba-fd5174e88ca1727a91d6dc9bf9bd898ff9087fe8.tar.gz
samba-fd5174e88ca1727a91d6dc9bf9bd898ff9087fe8.tar.bz2
samba-fd5174e88ca1727a91d6dc9bf9bd898ff9087fe8.zip
lib/util Split data_blob_hex_string() into upper and lower
Rather than have a repeat of the bugs we found at the plugfest where hexidecimal strings must be in upper or lower case in particular places, ensure that each caller chooses which case they want. This reverts most of the callers back to upper case, as things were before tridge's patch. The critical call in the extended DN code is of course handled in lower case. Andrew Bartlett
Diffstat (limited to 'lib/util/data_blob.c')
-rw-r--r--lib/util/data_blob.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/util/data_blob.c b/lib/util/data_blob.c
index 825d8cf88c..6e7557f8ef 100644
--- a/lib/util/data_blob.c
+++ b/lib/util/data_blob.c
@@ -153,7 +153,7 @@ _PUBLIC_ int data_blob_cmp(const DATA_BLOB *d1, const DATA_BLOB *d2)
/**
print the data_blob as hex string
**/
-_PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob)
+_PUBLIC_ char *data_blob_hex_string_lower(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob)
{
int i;
char *hex_string;
@@ -173,6 +173,23 @@ _PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob)
return hex_string;
}
+_PUBLIC_ char *data_blob_hex_string_upper(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;
+}
+
/**
useful for constructing data blobs in test suites, while
avoiding const warnings