diff --git a/pdf.c b/pdf.c index e8e339292d6b16bc120701d7ca4c47d168bd9846..8ae9e48bc6fcd06f8f69408f9025d5bf3d2a948e 100644 --- a/pdf.c +++ b/pdf.c @@ -4901,7 +4901,7 @@ parse_xrefs(struct Env *aux) size_t offset = 0; /* search for the "startxref" section from the back of the file */ - HParser *p = h_left(p_startxref, h_end_p()); + HParser *p = h_left(p_startxref, h_end_p()); // XXX alloc elsewhere? for (size_t i = 0; i < sz; i++) { res = h_parse(p, input + sz - i, i); if (res != NULL) @@ -4918,13 +4918,14 @@ parse_xrefs(struct Env *aux) // e.g. offset bounds, /Prev type/value, loop detection // verify the offset recovered is bounded to be in the file + // XXX this check is already present below by virtue of h_seek() if ( (offset <=0) || (offset >= aux->sz) ) { log_message(5, "VIOLATION[5]: Invalid xref table offset = %ld. Valid range <0, %ld>\n", offset, aux->sz); return; } - + // XXX try formulating this loop as one parser using h_seek and h_bind for (;;) { //res = h_parse(p_xref, input + offset, sz - offset); HParser *p = h_right(h_seek(offset * 8, SEEK_SET), p_xref);