charconv: Fix the slow-path character conversions
authorVolker Lendecke <vl@samba.org>
Tue, 29 Mar 2011 16:22:18 +0000 (18:22 +0200)
committerVolker Lendecke <vlendec@samba.org>
Tue, 29 Mar 2011 17:17:41 +0000 (19:17 +0200)
This reverts a part of 0189087e257f. That one might have fixed the fast path,
but it broke the slow path. convert_string_internal returns 0/-1 despite the
size_t result type and the misleading comment. If you follow the path to
smb_iconv and for example iconv_copy(), you will see that this routine returns
0 even after it copied something.

How to check: Use German locale, and do an smbclient "allinfo" on a file
modified in march (März in German). Notice the "ä". Before 0189087 this printed
correctly, after 0189087 it cut off the fields after the M for März.

Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Tue Mar 29 19:17:41 CEST 2011 on sn-devel-104

source3/lib/charcnv.c

index f95442a49f76fe965d49ee5bf4221d0baf393b6b..77e359d36298505af3237ead41e84c7ca36e5240 100644 (file)
@@ -187,7 +187,7 @@ size_t convert_string_error(charset_t from, charset_t to,
 #else
                                size_t ret = convert_string_internal(from, to, p, slen, q, dlen, converted_size);
                                if (converted_size) {
-                                       *converted_size = ret + retval;
+                                       *converted_size += retval;
                                }
                                return ret;
 #endif
@@ -231,7 +231,7 @@ size_t convert_string_error(charset_t from, charset_t to,
 #else
                                size_t ret = convert_string_internal(from, to, p, slen, q, dlen, converted_size);
                                if (converted_size) {
-                                       *converted_size = ret + retval;
+                                       *converted_size += retval;
                                }
                                return ret;
 #endif
@@ -275,7 +275,7 @@ size_t convert_string_error(charset_t from, charset_t to,
 #else
                                size_t ret = convert_string_internal(from, to, p, slen, q, dlen, converted_size);
                                if (converted_size) {
-                                       *converted_size = ret + retval;
+                                       *converted_size += retval;
                                }
                                return ret;
 #endif