From: Timo Sirainen Date: Fri, 23 Dec 2016 16:57:59 +0000 (-0500) Subject: lib: istream-jsonstr - return EPIPE if end-of-string quote isn't seen X-Git-Tag: 2.3.0.rc1~2368 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1547bafeb11368eb80168fe2899283e8bdcb8528;p=thirdparty%2Fdovecot%2Fcore.git lib: istream-jsonstr - return EPIPE if end-of-string quote isn't seen --- diff --git a/src/lib/istream-jsonstr.c b/src/lib/istream-jsonstr.c index 9cddbcc95f..8d4ee79ced 100644 --- a/src/lib/istream-jsonstr.c +++ b/src/lib/istream-jsonstr.c @@ -31,6 +31,11 @@ i_stream_jsonstr_read_parent(struct jsonstr_istream *jstream, stream->istream.stream_errno = stream->parent->stream_errno; stream->istream.eof = stream->parent->eof; + if (ret == -1 && stream->istream.stream_errno == 0) { + io_stream_set_error(&stream->iostream, + "EOF before trailing <\"> was seen"); + stream->istream.stream_errno = EPIPE; + } return ret; } size = i_stream_get_data_size(stream->parent); diff --git a/src/lib/test-istream-jsonstr.c b/src/lib/test-istream-jsonstr.c index e4f163840a..2be9f3478e 100644 --- a/src/lib/test-istream-jsonstr.c +++ b/src/lib/test-istream-jsonstr.c @@ -15,6 +15,9 @@ static const struct { { "\"", "", 0 }, { "foo\\?\"", "foo", EINVAL }, { "foo\\?\"", "foo", EINVAL }, + { "", "", EPIPE }, + { "\\\"", "\"", EPIPE }, + { "foo", "foo", EPIPE }, }; static void