]> arthur.barton.de Git - netatalk.git/commitdiff
make sure we return the right length in pre/decompose
authorbfernhomberg <bfernhomberg>
Mon, 22 Sep 2003 05:15:50 +0000 (05:15 +0000)
committerbfernhomberg <bfernhomberg>
Mon, 22 Sep 2003 05:15:50 +0000 (05:15 +0000)
libatalk/unicode/charcnv.c
libatalk/unicode/util_unistr.c

index dabbebd91bb3031a89f7875adca11423b6f84af4..43b240dc344edba974031abdbb4fb9d9b9076bfd 100644 (file)
@@ -951,6 +951,9 @@ size_t convert_charset ( charset_t from_set, charset_t to_set, charset_t cap_cha
                return (size_t) -1;
        }
 
+       if ( o_len == 0)
+               return o_len;
+
        /* Do pre/decomposition */
        if (CHECK_FLAGS(flags, CONV_PRECOMPOSE) || 
                ((!(charsets[to_set])   || !(charsets[to_set]->flags & CHARSET_DECOMPOSED)) && 
index c5717f2215d10fb52a4f8fbb0e8a4539f10e2d88..29f3d1302c55daf8e9de48845b4675184db7bccd 100644 (file)
@@ -407,7 +407,6 @@ size_t precompose_w (ucs2_t *name, size_t inplen, ucs2_t *comp, size_t *outlen)
                        in++;
                        if (i == inplen) {
                                *out = 0;
-                               *outlen -= 2;
                                return o_len - *outlen;
                        }
                        base = *in;
@@ -441,7 +440,6 @@ size_t decompose_w (ucs2_t *name, size_t inplen, ucs2_t *comp, size_t *outlen)
        out = (ucs2_t *)comp;
     
        while (i < inplen) {
-               //if (*outlen >= o_len/sizeof(u_int16_t) +2) {
                if (*outlen < 2) {
                        errno = E2BIG;
                        return (size_t)-1;
@@ -469,7 +467,6 @@ size_t decompose_w (ucs2_t *name, size_t inplen, ucs2_t *comp, size_t *outlen)
        }
 
        *out = 0;
-       *outlen -= 2;
        return o_len-*outlen;
 }