diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-06-18 17:01:33 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-06-18 17:17:25 +0200 |
commit | 7ee3ff576d308e838aa156226dea50a5909cebe3 (patch) | |
tree | ec3638968abadafc0a719e24f5f8ab689738427b /ffi | |
parent | ad3e80bab7e95b03c4e4e7297e8c376e7b83ddb2 (diff) |
openpgp: Propagate errors in `PacketParser::finish`.
Diffstat (limited to 'ffi')
-rw-r--r-- | ffi/include/sequoia/openpgp.h | 5 | ||||
-rw-r--r-- | ffi/src/openpgp.rs | 22 |
2 files changed, 21 insertions, 6 deletions
diff --git a/ffi/include/sequoia/openpgp.h b/ffi/include/sequoia/openpgp.h index f60b4a7b..c83fef5b 100644 --- a/ffi/include/sequoia/openpgp.h +++ b/ffi/include/sequoia/openpgp.h @@ -659,8 +659,9 @@ uint8_t *sq_packet_parser_buffer_unread_content (sq_context_t ctx, /// By default, this drops any unread content. Use, for instance, /// `PacketParserBuild` to customize the default behavior. /*/ -sq_packet_t sq_packet_parser_finish (sq_context_t ctx, - sq_packet_parser_t pp); +sq_status_t sq_packet_parser_finish (sq_context_t ctx, + sq_packet_parser_t pp, + sq_packet_t **packet); /*/ /// Tries to decrypt the current packet. diff --git a/ffi/src/openpgp.rs b/ffi/src/openpgp.rs index fb213cdc..86b50963 100644 --- a/ffi/src/openpgp.rs +++ b/ffi/src/openpgp.rs @@ -782,11 +782,25 @@ pub extern "system" fn sq_packet_parser_buffer_unread_content<'a> /// `PacketParserBuild` to customize the default behavior. #[no_mangle] pub extern "system" fn sq_packet_parser_finish<'a> - (ctx: Option<&mut Context>, pp: Option<&mut PacketParser<'a>>) - -> *const Packet { - let _ctx = ctx.expect("Context is NULL"); + (ctx: Option<&mut Context>, pp: Option<&mut PacketParser<'a>>, + packet: Option<&mut *const Packet>) + -> Status +{ + let ctx = ctx.expect("Context is NULL"); let pp = pp.expect("PacketParser is NULL"); - pp.finish() + match pp.finish() { + Ok(p) => { + if let Some(out_p) = packet { + *out_p = p; + } + Status::Success + }, + Err(e) => { + let status = Status::from(&e); + ctx.e = Some(e); + status + }, + } } /// Tries to decrypt the current packet. |