gpgparsemail: Die on parse error (not abort).

* tools/gpgparsemail.c (parse_message): Don't use ERRNO.
* tools/rfc822parse.c (transition_to_body): Return -1.
(transition_to_header, insert_header): Likewise.

--

GnuPG-bug-id: 1977
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2019-06-06 09:32:58 +09:00
parent 9bf650db02
commit c13e459ffe
2 changed files with 12 additions and 6 deletions

View File

@ -654,7 +654,7 @@ parse_message (FILE *fp)
if (rfc822parse_insert (msg, line, length))
die ("parser failed: %s", strerror (errno));
die ("parser failed");
if (info.hashing)
{

View File

@ -420,7 +420,9 @@ transition_to_body (rfc822parse_t msg)
s = rfc822parse_query_parameter (ctx, "boundary", 0);
if (s)
{
assert (!msg->current_part->boundary);
if (msg->current_part->boundary)
return -1;
msg->current_part->boundary = malloc (strlen (s) + 1);
if (msg->current_part->boundary)
{
@ -437,7 +439,8 @@ transition_to_body (rfc822parse_t msg)
return -1;
}
rc = do_callback (msg, RFC822PARSE_LEVEL_DOWN);
assert (!msg->current_part->down);
if (msg->current_part->down)
return -1;
msg->current_part->down = part;
msg->current_part = part;
msg->in_preamble = 1;
@ -458,8 +461,9 @@ transition_to_header (rfc822parse_t msg)
{
part_t part;
assert (msg->current_part);
assert (!msg->current_part->right);
if (!(msg->current_part
&& !msg->current_part->right))
return -1;
part = new_part ();
if (!part)
@ -476,7 +480,9 @@ insert_header (rfc822parse_t msg, const unsigned char *line, size_t length)
{
HDR_LINE hdr;
assert (msg->current_part);
if (!msg->current_part)
return -1;
if (!length)
{
msg->in_body = 1;