diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2017-01-17 14:33:02 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-01-17 17:15:59 +0100 |
commit | f8cc285a4a9f8f7ff5227de35aa52cde75c12cb9 (patch) | |
tree | d6d5fe25baa284736c6569e293e9cbc6921db170 /source/pdf | |
parent | ff90a2c02860bafc507dbcd76606f81261b64e34 (diff) | |
download | mupdf-f8cc285a4a9f8f7ff5227de35aa52cde75c12cb9.tar.xz |
pdf: Convert non-printable keywords into PDF_TOK_ERROR.
All known keywords are printable. Converting non-printable keywords into
error tokens means we don't try to print garbage when showing error
messages about unknown tokens.
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-lex.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source/pdf/pdf-lex.c b/source/pdf/pdf-lex.c index c7ba122b..34c753ab 100644 --- a/source/pdf/pdf-lex.c +++ b/source/pdf/pdf-lex.c @@ -35,6 +35,11 @@ static inline int iswhite(int ch) ch == '\040'; } +static inline int isprint(int ch) +{ + return ch >= ' ' && ch <= '~'; +} + static inline int unhex(int ch) { if (ch >= '0' && ch <= '9') return ch - '0'; @@ -439,8 +444,13 @@ pdf_token_from_keyword(char *key) case 'x': if (!strcmp(key, "xref")) return PDF_TOK_XREF; break; - default: - break; + } + + while (*key) + { + if (!isprint(*key)) + return PDF_TOK_ERROR; + ++key; } return PDF_TOK_KEYWORD; |