nls: utf8_wcstombs: use correct buffer size in error case
authorClemens Ladisch <clemens@ladisch.de>
Fri, 24 Apr 2009 08:11:40 +0000 (10:11 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 16 Jun 2009 04:44:43 +0000 (21:44 -0700)
When utf8_wcstombs encounters a character that cannot be encoded, we
must not decrease the remaining output buffer size because nothing has
been written to the output buffer.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/nls/nls_base.c

index 9b0efdad89100bd60e5a15954b67ca83495cad56..000736d89c9517ac531664191a5d6604f315a69b 100644 (file)
@@ -144,7 +144,6 @@ utf8_wcstombs(__u8 *s, const wchar_t *pwcs, int maxlen)
                        size = utf8_wctomb(op, *ip, maxlen);
                        if (size == -1) {
                                /* Ignore character and move on */
-                               maxlen--;
                        } else {
                                op += size;
                                maxlen -= size;