Here's what I propose to fix this, anything I'm missing?
Index: include/apr_xlate.h
===================================================================
--- include/apr_xlate.h (revision 106171)
+++ include/apr_xlate.h (working copy)
@@ -102,8 +102,15 @@
* @param outbytes_left Input: the size of the output buffer
* Output: the amount of the output buffer not yet used
* @remark
- * Return APR_ENOTIMPL if charset transcoding is not available
- * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined).
+ * Returns APR_ENOTIMPL if charset transcoding is not available
+ * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined).
+ * Returns APR_INCOMPLETE if the input buffer ends in an incomplete
+ * multi-byte character.
+ *
+ * To correctly terminate the output buffer for some multi-byte
+ * character set encodings, a final call must be made to this function
+ * after the complete input string has been converted, passing
+ * the inbuf and inbytes_left parameters as NULL.
*/
APU_DECLARE(apr_status_t) apr_xlate_conv_buffer(apr_xlate_t *convset,
const char *inbuf,
Index: xlate/xlate.c
===================================================================
--- xlate/xlate.c (revision 106171)
+++ xlate/xlate.c (working copy)
@@ -385,7 +385,7 @@
else
#endif
- {
+ if (inbuf) {
int to_convert = min(*inbytes_left, *outbytes_left);
int converted = to_convert;
char *table = convset->sbcs_table;
Index: test/testxlate.c
===================================================================
--- test/testxlate.c (revision 106171)
+++ test/testxlate.c (working copy)
@@ -53,6 +53,11 @@
&inbytes_left,
buf,
&outbytes_left);
+ if (status == APR_SUCCESS) {
+ status = apr_xlate_conv_buffer(convset, NULL, NULL,
+ buf + sizeof(buf) - outbytes_left - 1,
+ &outbytes_left);
+ }
buf[sizeof(buf) - outbytes_left - 1] = '\0';
retcode |= check_status(status, "apr_xlate_conv_buffer");
if ((!status || APR_STATUS_IS_INCOMPLETE(status))