-
Notifications
You must be signed in to change notification settings - Fork 471
Closed
Milestone
Description
utf8_toUtf8(const ENCODING *UNUSED_P(enc),
const char **fromP, const char *fromLim,
char **toP, const char *toLim)
{
char *to;
const char *from;
const char *fromLimInitial = fromLim;
/* Avoid copying partial characters. */
align_limit_to_full_utf8_characters(*fromP, &fromLim);
for (to = *toP, from = *fromP; (from < fromLim) && (to < toLim); from++, to++)
*to = *from;
*fromP = from;
*toP = to;
if (fromLim < fromLimInitial)
return XML_CONVERT_INPUT_INCOMPLETE;
else if ((to == toLim) && (from < fromLim))
// <===== Bug is here. In case (to == toLim), it's possible that
// from is still pointing to partial character. For example,
// a character with 3 bytes (A, B, C) and form is pointing to C.
// It means only A and B is copied to output buffer. Next
// scanning will start with C which could be considered as invalid
// byte and got dropped. After this, only "AB" is kept in memory
// and thus it will lead to invalid continuation byte.
return XML_CONVERT_OUTPUT_EXHAUSTED;
else
return XML_CONVERT_COMPLETED;
}
Metadata
Metadata
Assignees
Labels
No labels