aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2016-09-29 15:59:09 +0000
committerWerner Koch <[email protected]>2016-09-29 15:59:38 +0000
commitc738f92c195d91662ddc7848cc3c92c7f091f1f8 (patch)
tree19b9208f700708599eb824416944629c9fcfae7b
parenttools: Allow retrieval of signed data from mime-maker. (diff)
downloadgnupg-c738f92c195d91662ddc7848cc3c92c7f091f1f8.tar.gz
gnupg-c738f92c195d91662ddc7848cc3c92c7f091f1f8.zip
tools: Convey signeddata also to the part_data callback in mime-parser.
* tools/mime-parser.c (mime_parser_parse): Factor some code out to ... (process_part_data): new. ((mime_parser_parse): Also call process_part_data for signed data. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
-rw-r--r--tools/mime-parser.c58
1 files changed, 38 insertions, 20 deletions
diff --git a/tools/mime-parser.c b/tools/mime-parser.c
index 0ca5452c3..901781040 100644
--- a/tools/mime-parser.c
+++ b/tools/mime-parser.c
@@ -616,6 +616,35 @@ mime_parser_rfc822parser (mime_parser_t ctx)
}
+/* Helper for mime_parser_parse. */
+static gpg_error_t
+process_part_data (mime_parser_t ctx, char *line, size_t *length)
+{
+ gpg_error_t err;
+ size_t nbytes;
+
+ if (!ctx->want_part)
+ return 0;
+ if (!ctx->part_data)
+ return 0;
+
+ if (ctx->decode_part == 1)
+ {
+ *length = qp_decode (line, *length, NULL);
+ }
+ else if (ctx->decode_part == 2)
+ {
+ log_assert (ctx->b64state);
+ err = b64dec_proc (ctx->b64state, line, *length, &nbytes);
+ if (err)
+ return err;
+ *length = nbytes;
+ }
+
+ return ctx->part_data (ctx->cookie, line, *length);
+}
+
+
/* Read and parse a message from FP and call the appropriate
* callbacks. */
gpg_error_t
@@ -624,7 +653,7 @@ mime_parser_parse (mime_parser_t ctx, estream_t fp)
gpg_error_t err;
rfc822parse_t msg = NULL;
unsigned int lineno = 0;
- size_t length, nbytes;
+ size_t length;
char *line;
line = ctx->line;
@@ -741,6 +770,10 @@ mime_parser_parse (mime_parser_t ctx, estream_t fp)
ctx->collect_signeddata (ctx->cookie, line);
}
ctx->delay_hashing = 1;
+
+ err = process_part_data (ctx, line, &length);
+ if (err)
+ goto leave;
}
else if (ctx->pgpmime == PGPMIME_IN_SIGNATURE)
{
@@ -756,26 +789,11 @@ mime_parser_parse (mime_parser_t ctx, estream_t fp)
if (ctx->collect_signeddata)
ctx->collect_signature (ctx->cookie, NULL);
}
- else if (ctx->want_part)
+ else
{
- if (ctx->part_data)
- {
- if (ctx->decode_part == 1)
- {
- length = qp_decode (line, length, NULL);
- }
- else if (ctx->decode_part == 2)
- {
- log_assert (ctx->b64state);
- err = b64dec_proc (ctx->b64state, line, length, &nbytes);
- if (err)
- goto leave;
- length = nbytes;
- }
- err = ctx->part_data (ctx->cookie, line, length);
- if (err)
- goto leave;
- }
+ err = process_part_data (ctx, line, &length);
+ if (err)
+ goto leave;
}
}