util/charset/convert: when retrying, retry from the start
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 10 May 2019 07:32:39 +0000 (19:32 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 15 May 2019 04:03:37 +0000 (04:03 +0000)
iconv() advances the inbuf pointer; if we decide to realloc and re-iconv,
we need to reset inbuf to the source string

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/charset/convert_string.c

index 4591214..baff3d9 100644 (file)
@@ -351,7 +351,7 @@ bool convert_string_talloc_handle(TALLOC_CTX *ctx, struct smb_iconv_handle *ic,
 {
        size_t i_len, o_len, destlen;
        size_t retval;
-       const char *inbuf = (const char *)src;
+       const char *inbuf = NULL;
        char *outbuf = NULL, *ob = NULL;
        smb_iconv_t descriptor;
        void **dest = (void **)dst;
@@ -430,6 +430,7 @@ bool convert_string_talloc_handle(TALLOC_CTX *ctx, struct smb_iconv_handle *ic,
        outbuf = ob;
        i_len = srclen;
        o_len = destlen;
+       inbuf = (const char *)src;
 
        retval = smb_iconv(descriptor,
                           &inbuf, &i_len,