aboutsummaryrefslogtreecommitdiffstats
path: root/tools/rfc822parse.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2019-06-07 04:28:07 +0000
committerNIIBE Yutaka <[email protected]>2019-06-07 04:28:07 +0000
commit1e9d61fb95e4813225a40f720231196abdb83992 (patch)
tree9ee18aef2b0193ae7aeedcb26cf298b563b2e866 /tools/rfc822parse.c
parentscd: Bring back --card-timeout option as deprecated. (diff)
downloadgnupg-1e9d61fb95e4813225a40f720231196abdb83992.tar.gz
gnupg-1e9d61fb95e4813225a40f720231196abdb83992.zip
gpgparsemail: Die on parse error, printing errno thing.
* tools/gpgparsemail.c (parse_message): Revert the change. * tools/rfc822parse.c (transition_to_body): Set ERRNO. (transition_to_header, insert_header): Likewise. -- In the comment of rfc822parse_* functions, it explicitly explained setting ERRNO on error. For parser errors, it may not have appropriate ERRNO, in such a case, use ENOENT. Fixes-commit: c13e459ffeffb8c5387c44b3c04bb92b7111a75b Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'tools/rfc822parse.c')
-rw-r--r--tools/rfc822parse.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/rfc822parse.c b/tools/rfc822parse.c
index 0280796fe..ac6ecb17c 100644
--- a/tools/rfc822parse.c
+++ b/tools/rfc822parse.c
@@ -421,7 +421,10 @@ transition_to_body (rfc822parse_t msg)
if (s)
{
if (msg->current_part->boundary)
- return -1;
+ {
+ errno = ENOENT;
+ return -1;
+ }
msg->current_part->boundary = malloc (strlen (s) + 1);
if (msg->current_part->boundary)
@@ -440,7 +443,10 @@ transition_to_body (rfc822parse_t msg)
}
rc = do_callback (msg, RFC822PARSE_LEVEL_DOWN);
if (msg->current_part->down)
- return -1;
+ {
+ errno = ENOENT;
+ return -1;
+ }
msg->current_part->down = part;
msg->current_part = part;
msg->in_preamble = 1;
@@ -463,7 +469,10 @@ transition_to_header (rfc822parse_t msg)
if (!(msg->current_part
&& !msg->current_part->right))
- return -1;
+ {
+ errno = ENOENT;
+ return -1;
+ }
part = new_part ();
if (!part)
@@ -481,7 +490,10 @@ insert_header (rfc822parse_t msg, const unsigned char *line, size_t length)
HDR_LINE hdr;
if (!msg->current_part)
- return -1;
+ {
+ errno = ENOENT;
+ return -1;
+ }
if (!length)
{