The branch, master has been updated
       via  17b12ee1837671075b255c7703416db017d517e8 (commit)
      from  2c5221ef7a503ddfffa0d3b3209b3c2eda30b555 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 17b12ee1837671075b255c7703416db017d517e8
Author: Jelmer Vernooij <[EMAIL PROTECTED]>
Date:   Sat Oct 18 19:03:19 2008 +0200

    Add extra parameter consistent with samba3.

-----------------------------------------------------------------------

Summary of changes:
 lib/util/util.h     |    2 +-
 lib/util/util_str.c |   14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/util.h b/lib/util/util.h
index 38b5986..4c9a223 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -236,7 +236,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);
 
 /** 
  * Parse a hex string and return a data blob. 
diff --git a/lib/util/util_str.c b/lib/util/util_str.c
index afa772a..c105e1d 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;
 }


-- 
Samba Shared Repository

Reply via email to