commit b3dda3fe558da73e9b929790be8eb74afad337c6 from: Sven M. Hallberg date: Thu Mar 30 14:14:52 2023 UTC don't emulate VIOL in error messages While it might seem like a good idea to "grade" errors by severity, we are not *really* in any place to do so accurately. Our tasks are (a) to decide, internally, whether to print a message or silently ignore a malformation, and (b) to ultimately judge the file valid or invalid as a whole. Note that the latter part, as stated before, is not the responsibility of parse_xrefs(). Reinstate the input file name in these error messages. That information is useful when running the program on multiple files from a script, as we have been doing. While we're at it, fix style (line lengths). commit - 9ff8c465fbd3eb44f85988f3249768e4caa91ab0 commit + b3dda3fe558da73e9b929790be8eb74afad337c6 blob - c1652fb3cecf649ef9f0fb67ec86c3f24c612e00 blob + 04e077d7770c356c450863f0601ea7238b17d119 --- pdf.c +++ pdf.c @@ -4374,8 +4374,8 @@ process_page_content(struct Env *aux) // XXX validate the presence of this field elsewhere tok = dictentry(trailer, "Size"); if (tok == NULL || tok->token_type != TT_SINT) { - log_message(5, "VIOLATION[5]: error parsing trailer section!" - "Missing or malformed /Size field.\n"); + log_message(5, "%s: missing or malformed /Size in trailer\n", + aux->infile); return; } Size = H_CAST_SINT(tok); @@ -4968,7 +4968,7 @@ parse_xrefs(const uint8_t *input, size_t sz, size_t *n break; } if (res == NULL) { - log_message(5, "VIOLATION[5]: startxref not found\n"); + log_message(5, "%s: startxref not found\n", infile); goto end; } offset = H_INDEX_UINT(res->ast, 0); @@ -4979,8 +4979,8 @@ parse_xrefs(const uint8_t *input, size_t sz, size_t *n // 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 > sz) { - log_message(5, "VIOLATION[5]: startxref at %zu (%#zx) points outside the file\n", - sz - i, sz - i); + log_message(5, "%s: startxref value at %zu (%#zx) points " + "outside the file\n", sz - i, sz - i); goto end; } @@ -4989,8 +4989,8 @@ parse_xrefs(const uint8_t *input, size_t sz, size_t *n assert(offset <= sz); res = h_parse(p_xref, input + offset, sz - offset); if (res == NULL || res->ast == NULL || H_INDEX_TOKEN(res->ast, 0) == NULL) { - log_message(5, "VIOLATION[5]: error parsing xref section at " - "position %zu (%#zx)\n", offset, offset); + log_message(5, "%s: error parsing xref section at " + "position %zu (%#zx)\n", infile, offset, offset); break; }