diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-01-23 12:29:41 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-01-31 12:09:42 +0100 |
commit | 03dee17a4f84ee521f64778bb7441accb42e35b9 (patch) | |
tree | 771231b66a6f32dd28204070918d8112f45e0038 /source/pdf/pdf-lex.c | |
parent | 43e6a76ff86747501b77f2e485bdfcd8c067fb8f (diff) | |
download | mupdf-03dee17a4f84ee521f64778bb7441accb42e35b9.tar.xz |
Return PDF_TOK_ERROR when encountering isolated '>' and ')' characters.
Also return PDF_TOK_ERROR instead of swallowing string opening quotes in
pdf_lex_no_string.
Also fix the repair code to not skip an extra byte whenever it scans an error
token.
Diffstat (limited to 'source/pdf/pdf-lex.c')
-rw-r--r-- | source/pdf/pdf-lex.c | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/source/pdf/pdf-lex.c b/source/pdf/pdf-lex.c index fc439d17..1301c64a 100644 --- a/source/pdf/pdf-lex.c +++ b/source/pdf/pdf-lex.c @@ -521,32 +521,21 @@ pdf_lex(fz_context *ctx, fz_stream *f, pdf_lexbuf *buf) case '(': return lex_string(ctx, f, buf); case ')': - fz_warn(ctx, "lexical error (unexpected ')')"); - continue; + return PDF_TOK_ERROR; case '<': c = fz_read_byte(ctx, f); if (c == '<') - { return PDF_TOK_OPEN_DICT; - } - else - { + if (c != EOF) fz_unread_byte(ctx, f); - return lex_hex_string(ctx, f, buf); - } + return lex_hex_string(ctx, f, buf); case '>': c = fz_read_byte(ctx, f); if (c == '>') - { return PDF_TOK_CLOSE_DICT; - } - fz_warn(ctx, "lexical error (unexpected '>')"); - if (c == EOF) - { - return PDF_TOK_EOF; - } - fz_unread_byte(ctx, f); - continue; + if (c != EOF) + fz_unread_byte(ctx, f); + return PDF_TOK_ERROR; case '[': return PDF_TOK_OPEN_ARRAY; case ']': @@ -585,31 +574,23 @@ pdf_lex_no_string(fz_context *ctx, fz_stream *f, pdf_lexbuf *buf) lex_name(ctx, f, buf); return PDF_TOK_NAME; case '(': - continue; + return PDF_TOK_ERROR; /* no strings allowed */ case ')': - continue; + return PDF_TOK_ERROR; /* no strings allowed */ case '<': c = fz_read_byte(ctx, f); if (c == '<') - { return PDF_TOK_OPEN_DICT; - } - else - { - continue; - } + if (c != EOF) + fz_unread_byte(ctx, f); + return PDF_TOK_ERROR; /* no strings allowed */ case '>': c = fz_read_byte(ctx, f); if (c == '>') - { return PDF_TOK_CLOSE_DICT; - } - if (c == EOF) - { - return PDF_TOK_EOF; - } - fz_unread_byte(ctx, f); - continue; + if (c != EOF) + fz_unread_byte(ctx, f); + return PDF_TOK_ERROR; case '[': return PDF_TOK_OPEN_ARRAY; case ']': |