Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 May 2015 15:27:32 +0000 (UTC)
From:      Tijl Coosemans <tijl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r283406 - head/lib/libiconv_modules/UTF7
Message-ID:  <201505241527.t4OFRWqX051425@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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++;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505241527.t4OFRWqX051425>