summaryrefslogtreecommitdiff
path: root/lib/util/util_str.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-10-18 19:03:19 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-10-18 19:03:19 +0200
commit17b12ee1837671075b255c7703416db017d517e8 (patch)
treeeb6dbd7c48762af8dfa6ec2e540ea13eb927f6a0 /lib/util/util_str.c
parent2c5221ef7a503ddfffa0d3b3209b3c2eda30b555 (diff)
downloadsamba-17b12ee1837671075b255c7703416db017d517e8.tar.gz
samba-17b12ee1837671075b255c7703416db017d517e8.tar.bz2
samba-17b12ee1837671075b255c7703416db017d517e8.zip
Add extra parameter consistent with samba3.
Diffstat (limited to 'lib/util/util_str.c')
-rw-r--r--lib/util/util_str.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/util/util_str.c b/lib/util/util_str.c
index afa772a8a8..c105e1d58f 100644
--- a/lib/util/util_str.c
+++ b/lib/util/util_str.c
@@ -178,7 +178,7 @@ _PUBLIC_ char *safe_strcat(char *dest, const char *src, size_t maxlength)
**/
-_PUBLIC_ size_t strhex_to_str(char *p, size_t len, const char *strhex)
+_PUBLIC_ size_t strhex_to_str(char *p, size_t p_len, const char *strhex, size_t strhex_len)
{
size_t i;
size_t num_chars = 0;
@@ -186,7 +186,7 @@ _PUBLIC_ size_t strhex_to_str(char *p, size_t len, const char *strhex)
const char *hexchars = "0123456789ABCDEF";
char *p1 = NULL, *p2 = NULL;
- for (i = 0; i < len && strhex[i] != 0; i++) {
+ for (i = 0; i < strhex_len && strhex[i] != 0; i++) {
if (strncasecmp(hexchars, "0x", 2) == 0) {
i++; /* skip two chars */
continue;
@@ -204,6 +204,10 @@ _PUBLIC_ size_t strhex_to_str(char *p, size_t len, const char *strhex)
hinybble = PTR_DIFF(p1, hexchars);
lonybble = PTR_DIFF(p2, hexchars);
+ if (num_chars >= p_len) {
+ break;
+ }
+
p[num_chars] = (hinybble << 4) | lonybble;
num_chars++;
@@ -220,9 +224,9 @@ _PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *s
{
DATA_BLOB ret_blob = data_blob(mem_ctx, strlen(strhex)/2+1);
- ret_blob.length = strhex_to_str((char *)ret_blob.data,
- strlen(strhex),
- strhex);
+ ret_blob.length = strhex_to_str((char *)ret_blob.data, ret_blob.length,
+ strhex,
+ strlen(strhex));
return ret_blob;
}