]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: istream-jsonstr - return EPIPE if end-of-string quote isn't seen
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 23 Dec 2016 16:57:59 +0000 (11:57 -0500)
committerGitLab <gitlab@git.dovecot.net>
Fri, 23 Dec 2016 18:08:49 +0000 (20:08 +0200)
src/lib/istream-jsonstr.c
src/lib/test-istream-jsonstr.c

index 9cddbcc95fcd5ed5484b485b1494538352cc65bf..8d4ee79cedbbb07039752db3a0d54bb100f12bb0 100644 (file)
@@ -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);
index e4f163840a6ed4170a7c1775944e9711cbc2a174..2be9f3478e1d17d5849ff0891b97138bd60491af 100644 (file)
@@ -15,6 +15,9 @@ static const struct {
        { "\"", "", 0 },
        { "foo\\?\"", "foo", EINVAL },
        { "foo\\?\"", "foo", EINVAL },
+       { "", "", EPIPE },
+       { "\\\"", "\"", EPIPE },
+       { "foo", "foo", EPIPE },
 };
 
 static void