svn commit: r283406 - head/lib/libiconv_modules/UTF7
Tijl Coosemans
tijl at FreeBSD.org
Sun May 24 15:27:32 UTC 2015
Author: tijl
Date: Sun May 24 15:27:31 2015
New Revision: 283406
URL: https://svnweb.freebsd.org/changeset/base/283406
Log:
Fix decoding of UTF-7 when a base64 encoded chunk appears at the end of
the input buffer.
_citrus_UTF7_mbtoutf16 stored the decoder state at the beginning so it
could restore this state on an incomplete character such that the next
call would restart the decoding. The problem was that "-" (end of base64
mode) at the end of a string was also treated as an incomplete character
but was also removed from the state buffer. So the initial state would be
restored (with base64 mode) and the next call would no longer see the "-"
so it continued in base64 mode.
This state saving/restoring isn't needed here. It's already handled
elsewhere (citrus_iconv_std.c:_citrus_iconv_std_iconv_convert) so just
remove it.
Also initialise *nresult.
PR: 200398
Tested by: delphij
MFC after: 1 week
Modified:
head/lib/libiconv_modules/UTF7/citrus_utf7.c
Modified: head/lib/libiconv_modules/UTF7/citrus_utf7.c
==============================================================================
--- head/lib/libiconv_modules/UTF7/citrus_utf7.c Sun May 24 15:22:33 2015 (r283405)
+++ head/lib/libiconv_modules/UTF7/citrus_utf7.c Sun May 24 15:27:31 2015 (r283406)
@@ -154,21 +154,17 @@ _citrus_UTF7_mbtoutf16(_UTF7EncodingInfo
uint16_t * __restrict u16, char ** __restrict s, size_t n,
_UTF7State * __restrict psenc, size_t * __restrict nresult)
{
- _UTF7State sv;
char *s0;
int done, i, len;
+ *nresult = 0;
s0 = *s;
- sv = *psenc;
for (i = 0, done = 0; done == 0; i++) {
if (i == psenc->chlen) {
if (n-- < 1) {
*nresult = (size_t)-2;
*s = s0;
- sv.chlen = psenc->chlen;
- memcpy(sv.ch, psenc->ch, sizeof(sv.ch));
- *psenc = sv;
return (0);
}
psenc->ch[psenc->chlen++] = *s0++;
More information about the svn-src-head
mailing list