summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-lex.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2017-05-27 15:38:44 +0800
committerSebastian Rasmussen <sebras@gmail.com>2017-05-27 16:34:47 +0800
commit3b1083e580c59511f38cc7b6ac31544bedc60bb3 (patch)
tree444db707972b1f332f0b9ee085009880eccca02e /source/pdf/pdf-lex.c
parent571610edc07b46017dceb9bda6ebda09531fccf1 (diff)
downloadmupdf-3b1083e580c59511f38cc7b6ac31544bedc60bb3.tar.xz
Handle extremely long PDF names.
Previously the parser would cut these names short and then parse the remainder as a separate name.
Diffstat (limited to 'source/pdf/pdf-lex.c')
-rw-r--r--source/pdf/pdf-lex.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/source/pdf/pdf-lex.c b/source/pdf/pdf-lex.c
index ca4e42cf..74355d05 100644
--- a/source/pdf/pdf-lex.c
+++ b/source/pdf/pdf-lex.c
@@ -201,14 +201,20 @@ end:
}
static void
-lex_name(fz_context *ctx, fz_stream *f, pdf_lexbuf *buf)
+lex_name(fz_context *ctx, fz_stream *f, pdf_lexbuf *lb)
{
- char *s = buf->scratch;
- int n = buf->size;
+ char *s = lb->scratch;
+ char *e = s + lb->size;
+ int c;
- while (n > 1)
+ while (1)
{
- int c = fz_read_byte(ctx, f);
+ if (s == e)
+ {
+ s += pdf_lexbuf_grow(ctx, lb);
+ e = lb->scratch + lb->size;
+ }
+ c = fz_read_byte(ctx, f);
switch (c)
{
case IS_WHITE:
@@ -255,22 +261,19 @@ lex_name(fz_context *ctx, fz_stream *f, pdf_lexbuf *buf)
/* fallthrough */
case EOF:
*s++ = d;
- n--;
goto end;
}
*s++ = d + c;
- n--;
break;
}
default:
*s++ = c;
- n--;
break;
}
}
end:
*s = '\0';
- buf->len = s - buf->scratch;
+ lb->len = s - lb->scratch;
}
static int