diff options
Diffstat (limited to 'tools/rfc822parse.c')
-rw-r--r-- | tools/rfc822parse.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/tools/rfc822parse.c b/tools/rfc822parse.c index f1e95bd34..ac6ecb17c 100644 --- a/tools/rfc822parse.c +++ b/tools/rfc822parse.c @@ -420,7 +420,12 @@ 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) + { + errno = ENOENT; + return -1; + } + msg->current_part->boundary = malloc (strlen (s) + 1); if (msg->current_part->boundary) { @@ -437,7 +442,11 @@ 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) + { + errno = ENOENT; + return -1; + } msg->current_part->down = part; msg->current_part = part; msg->in_preamble = 1; @@ -458,8 +467,12 @@ 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)) + { + errno = ENOENT; + return -1; + } part = new_part (); if (!part) @@ -476,7 +489,12 @@ insert_header (rfc822parse_t msg, const unsigned char *line, size_t length) { HDR_LINE hdr; - assert (msg->current_part); + if (!msg->current_part) + { + errno = ENOENT; + return -1; + } + if (!length) { msg->in_body = 1; |