The branch, v3-2-test has been updated
       via  5109bd33719a4bb1534cb0e012c92ec778fb26df (commit)
      from  09fa53d927436310ae3c17096d42e2fa4de1dd2e (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 5109bd33719a4bb1534cb0e012c92ec778fb26df
Author: Jeremy Allison <[EMAIL PROTECTED]>
Date:   Thu Oct 16 15:06:13 2008 -0700

    Unify the logic in pull_ascii_base_talloc() and pull_ucs2_base_talloc().
    Jeremy.

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

Summary of changes:
 source/lib/charcnv.c |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/charcnv.c b/source/lib/charcnv.c
index eec7ae3..f4efcb2 100644
--- a/source/lib/charcnv.c
+++ b/source/lib/charcnv.c
@@ -1183,6 +1183,10 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx,
 
        *ppdest = NULL;
 
+       if (!src_len) {
+               return 0;
+       }
+
        if (flags & STR_TERMINATE) {
                if (src_len == (size_t)-1) {
                        src_len = strlen((const char *)src) + 1;
@@ -1200,11 +1204,22 @@ static size_t pull_ascii_base_talloc(TALLOC_CTX *ctx,
                                        (unsigned int)src_len);
                        smb_panic(msg);
                }
+       } else {
+               /* Can't have an unlimited length
+                * non STR_TERMINATE'd.
+                */
+               if (src_len == (size_t)-1) {
+                       errno = EINVAL;
+                       return 0;
+               }
        }
 
+       /* src_len != -1 here. */
+
        if (!convert_string_allocate(ctx, CH_DOS, CH_UNIX, src, src_len, &dest,
-               &dest_len, True))
+               &dest_len, True)) {
                dest_len = 0;
+       }
 
        if (dest_len && dest) {
                /* Did we already process the terminating zero ? */
@@ -1571,12 +1586,20 @@ size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx,
                if (src_len >= 1024*1024) {
                        smb_panic("Bad src length in pull_ucs2_base_talloc\n");
                }
+       } else {
+               /* Can't have an unlimited length
+                * non STR_TERMINATE'd.
+                */
+               if (src_len == (size_t)-1) {
+                       errno = EINVAL;
+                       return 0;
+               }
        }
 
+       /* src_len != -1 here. */
+
        /* ucs2 is always a multiple of 2 bytes */
-       if (src_len != (size_t)-1) {
-               src_len &= ~1;
-       }
+       src_len &= ~1;
 
        dest_len = convert_string_talloc(ctx,
                                        CH_UTF16LE,
@@ -1589,9 +1612,6 @@ size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx,
                dest_len = 0;
        }
 
-       if (src_len == (size_t)-1)
-               src_len = dest_len*2;
-
        if (dest_len) {
                /* Did we already process the terminating zero ? */
                if (dest[dest_len-1] != 0) {


-- 
Samba Shared Repository

Reply via email to