apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <...@manyfish.co.uk>
Subject nasty apr-util xlate bug
Date Fri, 19 Mar 2004 01:17:58 GMT
I was investigating one AIX problem and came across a different one:

http://www.contactor.se/~dast/svn/archive-2003-03/1565.shtml

the cause seems to be the check_sbcs function in xlate.c.

The convset->ich is set up to convert from UTF-8 to ISO-8895-1;
check_sbcs fails to create the sbcs table for this case, of course.  But
the iconv state is not reset, and it was by design left part-way through
a UTF-8 sequence: so when a subsequent conv_buffer calls come along to
reuse iconv->ich, expecting it to be in the initial state, it all goes
horribly wrong.

The iconv(, NULL, NULL, NULL, NULL)-type calls to reset to the initial
conversion state segfaulted on AIX so it seems necessary to recreate the
cd, as per below... the same problem exists in the apr_iconv-based
implementation I guess.

Am I missing anything? Not sure why this problem doesn't affect more
users.

--- xlate/xlate.c	13 Feb 2004 09:55:27 -0000	1.19
+++ xlate/xlate.c	19 Mar 2004 01:06:48 -0000
@@ -132,6 +132,11 @@
         convset->ich = (iconv_t)-1;
 
         /* TODO: add the table to the cache */
+    } else {
+        /* reopen the iconv cd to get back to initial conversion
+         * state */
+        iconv_close(convset->ich);
+        convset->ich = iconv_open(convset->topage, convset->frompage);
     }
 }
 #elif APU_HAVE_APR_ICONV

Mime
View raw message