From 0f4f9f6d91f1f842f8cf6691cfcd39d34234adcd Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 28 Jun 2008 22:03:43 +0000 Subject: Make iconv-based filtering produce correct output when encountering encoding errors. Fix inputstream_peek_slow to flag OOD when the buffer fill routine produces no new data. svn path=/trunk/libparserutils/; revision=4474 --- src/input/filter.c | 10 ++++++++++ src/input/inputstream.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/input') diff --git a/src/input/filter.c b/src/input/filter.c index f40c98f..4a7cd7f 100644 --- a/src/input/filter.c +++ b/src/input/filter.c @@ -204,6 +204,16 @@ parserutils_error parserutils_filter_process_chunk(parserutils_filter *input, if (ret != (size_t) -1 || errno != EILSEQ) break; + if (*outlen < 3) + return PARSERUTILS_NOMEM; + + (*output)[0] = 0xef; + (*output)[1] = 0xbf; + (*output)[2] = 0xbd; + + *output += 3; + *outlen -= 3; + (*data)++; (*len)--; } diff --git a/src/input/inputstream.c b/src/input/inputstream.c index 9cbcdd2..5631331 100644 --- a/src/input/inputstream.c +++ b/src/input/inputstream.c @@ -235,7 +235,8 @@ uintptr_t parserutils_inputstream_peek_slow(parserutils_inputstream *stream, /* Refill utf8 buffer from raw buffer */ error = parserutils_inputstream_refill_buffer(s); - if (error != PARSERUTILS_OK) + if (error != PARSERUTILS_OK || + s->public.cursor + offset == s->public.utf8->length) return PARSERUTILS_INPUTSTREAM_OOD; /* Now try the read */ -- cgit v1.2.3