aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2019-06-06 00:32:58 +0000
committerNIIBE Yutaka <[email protected]>2019-06-06 00:32:58 +0000
commitc13e459ffeffb8c5387c44b3c04bb92b7111a75b (patch)
treef29b803a4e19814013b8e051623a109bde415676
parentsm: Print a better diagnostic for encryption certificate selection. (diff)
downloadgnupg-c13e459ffeffb8c5387c44b3c04bb92b7111a75b.tar.gz
gnupg-c13e459ffeffb8c5387c44b3c04bb92b7111a75b.zip
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 <[email protected]>
-rw-r--r--tools/gpgparsemail.c2
-rw-r--r--tools/rfc822parse.c16
2 files changed, 12 insertions, 6 deletions
diff --git a/tools/gpgparsemail.c b/tools/gpgparsemail.c
index b12209755..c5f4e6cd0 100644
--- a/tools/gpgparsemail.c
+++ b/tools/gpgparsemail.c
@@ -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)
{
diff --git a/tools/rfc822parse.c b/tools/rfc822parse.c
index f1e95bd34..0280796fe 100644
--- a/tools/rfc822parse.c
+++ b/tools/rfc822parse.c
@@ -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;