diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-01-16 13:46:31 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-01-16 13:52:53 +0100 |
commit | e76820f4750e83897de5087c082d0e546ed70a00 (patch) | |
tree | 7f0d6ad99c0458a6457fe82d5374345846d6a91c /ffi/src | |
parent | 83873fca4714be6ceb264d6d1ca7d56b4fda8150 (diff) |
ffi: Wrap every function using ffi_catch_abort.
- This prevents stack unwinding across the FFI boundary.
- Fixes #161.
Diffstat (limited to 'ffi/src')
-rw-r--r-- | ffi/src/core.rs | 54 | ||||
-rw-r--r-- | ffi/src/error.rs | 6 | ||||
-rw-r--r-- | ffi/src/lib.rs | 3 | ||||
-rw-r--r-- | ffi/src/net.rs | 12 | ||||
-rw-r--r-- | ffi/src/openpgp/armor.rs | 12 | ||||
-rw-r--r-- | ffi/src/openpgp/crypto.rs | 8 | ||||
-rw-r--r-- | ffi/src/openpgp/fingerprint.rs | 20 | ||||
-rw-r--r-- | ffi/src/openpgp/keyid.rs | 16 | ||||
-rw-r--r-- | ffi/src/openpgp/mod.rs | 142 | ||||
-rw-r--r-- | ffi/src/openpgp/packet_pile.rs | 12 | ||||
-rw-r--r-- | ffi/src/openpgp/tpk.rs | 84 | ||||
-rw-r--r-- | ffi/src/openpgp/tsk.rs | 10 | ||||
-rw-r--r-- | ffi/src/store.rs | 72 |
13 files changed, 227 insertions, 224 deletions
diff --git a/ffi/src/core.rs b/ffi/src/core.rs index 88ee0570..5f545702 100644 --- a/ffi/src/core.rs +++ b/ffi/src/core.rs @@ -68,7 +68,7 @@ impl Context { /// Returns the last error. /// /// Returns and removes the last error from the context. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_context_last_error(ctx: *mut Context) -> *mut failure::Error { let ctx = ffi_param_ref_mut!(ctx); @@ -83,7 +83,7 @@ pub extern "system" fn sq_context_last_error(ctx: *mut Context) /// /// Returns `NULL` on errors. If `errp` is not `NULL`, the error is /// stored there. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_context_new(domain: *const c_char, errp: Option<&mut *mut failure::Error>) -> *mut Context { @@ -102,7 +102,7 @@ pub extern "system" fn sq_context_new(domain: *const c_char, } /// Frees a context. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_context_free(context: Option<&mut Context>) { ffi_free!(context) } @@ -116,7 +116,7 @@ pub extern "system" fn sq_context_free(context: Option<&mut Context>) { /// The configuration is seeded like in `sq_context_new`, but can be /// modified. A configuration has to be finalized using /// `sq_config_build()` in order to turn it into a Context. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_context_configure(domain: *const c_char) -> *mut Config { let domain = ffi_param_cstr!(domain).to_string_lossy(); @@ -125,42 +125,42 @@ pub extern "system" fn sq_context_configure(domain: *const c_char) } /// Returns the domain of the context. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_context_domain(ctx: *const Context) -> *const c_char { let ctx = ffi_param_ref!(ctx); ctx.c.domain().as_bytes().as_ptr() as *const c_char } /// Returns the directory containing shared state. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_context_home(ctx: *const Context) -> *const c_char { let ctx = ffi_param_ref!(ctx); ctx.c.home().to_string_lossy().as_ptr() as *const c_char } /// Returns the directory containing backend servers. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_context_lib(ctx: *const Context) -> *const c_char { let ctx = ffi_param_ref!(ctx); ctx.c.lib().to_string_lossy().as_bytes().as_ptr() as *const c_char } /// Returns the network policy. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_context_network_policy(ctx: *const Context) -> c_int { let ctx = ffi_param_ref!(ctx); u8::from(ctx.c.network_policy()) as c_int } /// Returns the IPC policy. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_context_ipc_policy(ctx: *const Context) -> c_int { let ctx = ffi_param_ref!(ctx); u8::from(ctx.c.ipc_policy()) as c_int } /// Returns whether or not this is an ephemeral context. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_context_ephemeral(ctx: *const Context) -> uint8_t { let ctx = ffi_param_ref!(ctx); if ctx.c.ephemeral() { 1 } else { 0 } @@ -173,7 +173,7 @@ pub extern "system" fn sq_context_ephemeral(ctx: *const Context) -> uint8_t { /// /// Consumes `cfg`. Returns `NULL` on errors. Returns `NULL` on /// errors. If `errp` is not `NULL`, the error is stored there. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_config_build(cfg: *mut Config, errp: Option<&mut *mut failure::Error>) -> *mut Context { @@ -192,7 +192,7 @@ pub extern "system" fn sq_config_build(cfg: *mut Config, } /// Sets the directory containing shared state. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_config_home(cfg: *mut Config, home: *const c_char) { let cfg = ffi_param_ref_mut!(cfg); @@ -201,7 +201,7 @@ pub extern "system" fn sq_config_home(cfg: *mut Config, } /// Set the directory containing backend servers. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_config_lib(cfg: *mut Config, lib: *const c_char) { let cfg = ffi_param_ref_mut!(cfg); @@ -210,7 +210,7 @@ pub extern "system" fn sq_config_lib(cfg: *mut Config, } /// Sets the network policy. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_config_network_policy(cfg: *mut Config, policy: c_int) { let cfg = ffi_param_ref_mut!(cfg); @@ -221,7 +221,7 @@ pub extern "system" fn sq_config_network_policy(cfg: *mut Config, } /// Sets the IPC policy. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_config_ipc_policy(cfg: *mut Config, policy: c_int) { let cfg = ffi_param_ref_mut!(cfg); @@ -232,7 +232,7 @@ pub extern "system" fn sq_config_ipc_policy(cfg: *mut Config, } /// Makes this context ephemeral. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_config_ephemeral(cfg: *mut Config) { let cfg = ffi_param_ref_mut!(cfg); cfg.set_ephemeral(); @@ -241,7 +241,7 @@ pub extern "system" fn sq_config_ephemeral(cfg: *mut Config) { /* Reader and writer. */ /// Opens a file returning a reader. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_reader_from_file(ctx: *mut Context, filename: *const c_char) -> *mut Box<Read> { @@ -254,14 +254,14 @@ pub extern "system" fn sq_reader_from_file(ctx: *mut Context, /// Opens a file descriptor returning a reader. #[cfg(unix)] -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_reader_from_fd(fd: c_int) -> *mut Box<Read> { box_raw!(Box::new(unsafe { File::from_raw_fd(fd) })) } /// Creates a reader from a buffer. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_reader_from_bytes(buf: *const uint8_t, len: size_t) -> *mut Box<Read> { @@ -273,13 +273,13 @@ pub extern "system" fn sq_reader_from_bytes(buf: *const uint8_t, } /// Frees a reader. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_reader_free(reader: Option<&mut Box<Read>>) { ffi_free!(reader) } /// Reads up to `len` bytes into `buf`. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_reader_read(ctx: *mut Context, reader: *mut Box<Read>, buf: *mut uint8_t, len: size_t) @@ -298,7 +298,7 @@ pub extern "system" fn sq_reader_read(ctx: *mut Context, /// /// The file will be created if it does not exist, or be truncated /// otherwise. If you need more control, use `sq_writer_from_fd`. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_writer_from_file(ctx: *mut Context, filename: *const c_char) -> *mut Box<Write> { @@ -311,14 +311,14 @@ pub extern "system" fn sq_writer_from_file(ctx: *mut Context, /// Opens a file descriptor returning a writer. #[cfg(unix)] -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_writer_from_fd(fd: c_int) -> *mut Box<Write> { box_raw!(Box::new(unsafe { File::from_raw_fd(fd) })) } /// Creates a writer from a buffer. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_writer_from_bytes(buf: *mut uint8_t, len: size_t) -> *mut Box<Write> { @@ -337,7 +337,7 @@ pub extern "system" fn sq_writer_from_bytes(buf: *mut uint8_t, /// reference a chunk of memory allocated using libc's heap allocator. /// The caller is responsible to `free` it once the writer has been /// destroyed. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_writer_alloc(buf: *mut *mut c_void, len: *mut size_t) -> *mut Box<Write> { @@ -384,13 +384,13 @@ impl Write for WriterAlloc { } /// Frees a writer. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_writer_free(writer: Option<&mut Box<Write>>) { ffi_free!(writer) } /// Writes up to `len` bytes of `buf` into `writer`. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_writer_write(ctx: *mut Context, writer: *mut Box<Write>, buf: *const uint8_t, len: size_t) diff --git a/ffi/src/error.rs b/ffi/src/error.rs index e6ae201b..369cbb25 100644 --- a/ffi/src/error.rs +++ b/ffi/src/error.rs @@ -8,7 +8,7 @@ extern crate sequoia_openpgp as openpgp; use sequoia_core as core; /// Frees an error. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_error_free(error: Option<&mut failure::Error>) { ffi_free!(error) } @@ -16,7 +16,7 @@ pub extern "system" fn sq_error_free(error: Option<&mut failure::Error>) { /// Returns the error message. /// /// The returned value must be freed with `free(3)`. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_error_string(error: *const failure::Error) -> *mut c_char { let error = ffi_param_ref!(error); @@ -24,7 +24,7 @@ pub extern "system" fn sq_error_string(error: *const failure::Error) } /// Returns the error status code. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_error_status(error: *const failure::Error) -> Status { let error = ffi_param_ref!(error); diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs index 236f8695..a2b8269c 100644 --- a/ffi/src/lib.rs +++ b/ffi/src/lib.rs @@ -121,6 +121,9 @@ extern crate failure; extern crate lazy_static; extern crate libc; extern crate native_tls; + +extern crate sequoia_ffi_macros; +use sequoia_ffi_macros::ffi_catch_abort; extern crate sequoia_core; extern crate sequoia_net; extern crate sequoia_store; diff --git a/ffi/src/net.rs b/ffi/src/net.rs index 6935a564..7d1558f6 100644 --- a/ffi/src/net.rs +++ b/ffi/src/net.rs @@ -47,7 +47,7 @@ use super::core::Context; /// e.g. `hkps://examle.org`. /// /// Returns `NULL` on errors. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyserver_new(ctx: *mut Context, uri: *const c_char) -> *mut KeyServer { let ctx = ffi_param_ref_mut!(ctx); @@ -63,7 +63,7 @@ pub extern "system" fn sq_keyserver_new(ctx: *mut Context, /// size `len` used to authenticate the server. /// /// Returns `NULL` on errors. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyserver_with_cert(ctx: *mut Context, uri: *const c_char, cert: *const uint8_t, @@ -91,7 +91,7 @@ pub extern "system" fn sq_keyserver_with_cert(ctx: *mut Context, /// included in this library. It is a good default choice. /// /// Returns `NULL` on errors. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyserver_sks_pool(ctx: *mut Context) -> *mut KeyServer { let ctx = ffi_param_ref_mut!(ctx); @@ -99,7 +99,7 @@ pub extern "system" fn sq_keyserver_sks_pool(ctx: *mut Context) } /// Frees a keyserver object. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyserver_free(ks: Option<&mut KeyServer>) { ffi_free!(ks) } @@ -107,7 +107,7 @@ pub extern "system" fn sq_keyserver_free(ks: Option<&mut KeyServer>) { /// Retrieves the key with the given `keyid`. /// /// Returns `NULL` on errors. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyserver_get(ctx: *mut Context, ks: *mut KeyServer, id: *const KeyID) @@ -122,7 +122,7 @@ pub extern "system" fn sq_keyserver_get(ctx: *mut Context, /// Sends the given key to the server. /// /// Returns != 0 on errors. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyserver_send(ctx: *mut Context, ks: *mut KeyServer, tpk: *const TPK) diff --git a/ffi/src/openpgp/armor.rs b/ffi/src/openpgp/armor.rs index c51b289b..3680b74e 100644 --- a/ffi/src/openpgp/armor.rs +++ b/ffi/src/openpgp/armor.rs @@ -128,7 +128,7 @@ fn kind_to_int(kind: Option<armor::Kind>) -> c_int { /// return 0; /// } /// ``` -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_armor_reader_new(inner: *mut Box<Read>, kind: c_int) -> *mut Box<Read> { @@ -139,7 +139,7 @@ pub extern "system" fn sq_armor_reader_new(inner: *mut Box<Read>, } /// Creates a `Reader` from a file. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_armor_reader_from_file(ctx: *mut Context, filename: *const c_char, kind: c_int) @@ -154,7 +154,7 @@ pub extern "system" fn sq_armor_reader_from_file(ctx: *mut Context, } /// Creates a `Reader` from a buffer. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_armor_reader_from_bytes(b: *const uint8_t, len: size_t, kind: c_int) -> *mut Box<Read> { @@ -178,7 +178,7 @@ pub extern "system" fn sq_armor_reader_from_bytes(b: *const uint8_t, len: size_t /// See [this] example. /// /// [this]: fn.sq_armor_reader_new.html -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_armor_reader_kind(reader: *mut Box<Read>) -> c_int { // We need to downcast `reader`. To do that, we need to do a @@ -208,7 +208,7 @@ pub extern "system" fn sq_armor_reader_kind(reader: *mut Box<Read>) /// See [this] example. /// /// [this]: fn.sq_armor_reader_new.html -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_armor_reader_headers(ctx: *mut Context, reader: *mut Box<Read>, len: *mut size_t) @@ -339,7 +339,7 @@ fn strdup(s: &str) -> *mut c_char { /// return 0; /// } /// ``` -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_armor_writer_new (ctx: *mut Context, inner: *mut Box<Write>, diff --git a/ffi/src/openpgp/crypto.rs b/ffi/src/openpgp/crypto.rs index 4236568f..b4da7553 100644 --- a/ffi/src/openpgp/crypto.rs +++ b/ffi/src/openpgp/crypto.rs @@ -13,7 +13,7 @@ use self::sequoia_openpgp::{ }; /// Frees a signer. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_signer_free (s: Option<&mut &'static mut crypto::Signer>) { @@ -21,7 +21,7 @@ pub extern "system" fn sq_signer_free } /// Creates a new key pair. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_key_pair_new (ctx: *mut Context, public: *mut Key, secret: *mut crypto::mpis::SecretKey) -> *mut crypto::KeyPair @@ -33,7 +33,7 @@ pub extern "system" fn sq_key_pair_new } /// Frees a key pair. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_key_pair_free (kp: Option<&mut crypto::KeyPair>) { @@ -44,7 +44,7 @@ pub extern "system" fn sq_key_pair_free /// /// Note that the returned object merely references the key pair, and /// must not outlive the key pair. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_key_pair_as_signer (kp: *mut crypto::KeyPair) -> *mut &'static mut crypto::Signer diff --git a/ffi/src/openpgp/fingerprint.rs b/ffi/src/openpgp/fingerprint.rs index 8e94886a..0a043762 100644 --- a/ffi/src/openpgp/fingerprint.rs +++ b/ffi/src/openpgp/fingerprint.rs @@ -15,7 +15,7 @@ use self::sequoia_openpgp::{Fingerprint, KeyID}; use build_hasher; /// Reads a binary fingerprint. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_fingerprint_from_bytes(buf: *const uint8_t, len: size_t) -> *mut Fingerprint { @@ -27,7 +27,7 @@ pub extern "system" fn sq_fingerprint_from_bytes(buf: *const uint8_t, } /// Reads a hexadecimal fingerprint. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_fingerprint_from_hex(hex: *const c_char) -> *mut Fingerprint { let hex = ffi_param_cstr!(hex).to_string_lossy(); @@ -37,13 +37,13 @@ pub extern "system" fn sq_fingerprint_from_hex(hex: *const c_char) } /// Frees a sq_fingerprint_t. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_fingerprint_free(fp: Option<&mut Fingerprint>) { ffi_free!(fp) } /// Clones the Fingerprint. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_fingerprint_clone(fp: *const Fingerprint) -> *mut Fingerprint { let fp = ffi_param_ref!(fp); @@ -51,7 +51,7 @@ pub extern "system" fn sq_fingerprint_clone(fp: *const Fingerprint) } /// Hashes the Fingerprint. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_fingerprint_hash(fp: *const Fingerprint) -> uint64_t { let fp = ffi_param_ref!(fp); @@ -64,7 +64,7 @@ pub extern "system" fn sq_fingerprint_hash(fp: *const Fingerprint) /// /// This returns a reference to the internal buffer that is valid as /// long as the fingerprint is. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_fingerprint_as_bytes(fp: *const Fingerprint, fp_len: Option<&mut size_t>) -> *const uint8_t { @@ -76,7 +76,7 @@ pub extern "system" fn sq_fingerprint_as_bytes(fp: *const Fingerprint, } /// Converts the fingerprint to its standard representation. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_fingerprint_to_string(fp: *const Fingerprint) -> *mut c_char { let fp = ffi_param_ref!(fp); @@ -84,7 +84,7 @@ pub extern "system" fn sq_fingerprint_to_string(fp: *const Fingerprint) } /// Converts the fingerprint to a hexadecimal number. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_fingerprint_to_hex(fp: *const Fingerprint) -> *mut c_char { let fp = ffi_param_ref!(fp); @@ -92,7 +92,7 @@ pub extern "system" fn sq_fingerprint_to_hex(fp: *const Fingerprint) } /// Converts the fingerprint to a key ID. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_fingerprint_to_keyid(fp: *const Fingerprint) -> *mut KeyID { let fp = ffi_param_ref!(fp); @@ -100,7 +100,7 @@ pub extern "system" fn sq_fingerprint_to_keyid(fp: *const Fingerprint) } /// Compares Fingerprints. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_fingerprint_equal(a: *const Fingerprint, b: *const Fingerprint) -> bool { diff --git a/ffi/src/openpgp/keyid.rs b/ffi/src/openpgp/keyid.rs index bdb93b2d..2b8d3e2e 100644 --- a/ffi/src/openpgp/keyid.rs +++ b/ffi/src/openpgp/keyid.rs @@ -32,7 +32,7 @@ use build_hasher; /// sq_keyid_free (mr_b); /// free (mr_b_as_string); /// ``` -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyid_from_bytes(id: *const uint8_t) -> *mut KeyID { assert!(!id.is_null()); let id = unsafe { slice::from_raw_parts(id, 8) }; @@ -40,7 +40,7 @@ pub extern "system" fn sq_keyid_from_bytes(id: *const uint8_t) -> *mut KeyID { } /// Reads a hex-encoded Key ID. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyid_from_hex(id: *const c_char) -> *mut KeyID { let id = ffi_param_cstr!(id).to_string_lossy(); KeyID::from_hex(&id) @@ -49,13 +49,13 @@ pub extern "system" fn sq_keyid_from_hex(id: *const c_char) -> *mut KeyID { } /// Frees an `KeyID` object. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyid_free(keyid: Option<&mut KeyID>) { ffi_free!(keyid) } /// Clones the KeyID. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyid_clone(id: *const KeyID) -> *mut KeyID { let id = ffi_param_ref!(id); @@ -63,7 +63,7 @@ pub extern "system" fn sq_keyid_clone(id: *const KeyID) } /// Hashes the KeyID. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyid_hash(id: *const KeyID) -> uint64_t { let id = ffi_param_ref!(id); @@ -73,7 +73,7 @@ pub extern "system" fn sq_keyid_hash(id: *const KeyID) } /// Converts the KeyID to its standard representation. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyid_to_string(id: *const KeyID) -> *mut c_char { let id = ffi_param_ref!(id); @@ -81,7 +81,7 @@ pub extern "system" fn sq_keyid_to_string(id: *const KeyID) } /// Converts the KeyID to a hexadecimal number. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyid_to_hex(id: *const KeyID) -> *mut c_char { let id = ffi_param_ref!(id); @@ -89,7 +89,7 @@ pub extern "system" fn sq_keyid_to_hex(id: *const KeyID) } /// Compares KeyIDs. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_keyid_equal(a: *const KeyID, b: *const KeyID) -> bool { diff --git a/ffi/src/openpgp/mod.rs b/ffi/src/openpgp/mod.rs index 9fe0022d..3f74263b 100644 --- a/ffi/src/openpgp/mod.rs +++ b/ffi/src/openpgp/mod.rs @@ -69,7 +69,7 @@ pub mod tsk; /// /// assert (strcmp (sq_tag_to_string (2), "SIGNATURE") == 0); /// ``` -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_tag_to_string(tag: u8) -> *const c_char { match Tag::from(tag) { Tag::PKESK => "PKESK\x00", @@ -102,7 +102,7 @@ fn revocation_status_to_int(rs: &RevocationStatus) -> c_int { } /// Returns the TPK's revocation status variant. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_revocation_status_variant( rs: *mut RevocationStatus) -> c_int @@ -114,7 +114,7 @@ pub extern "system" fn sq_revocation_status_variant( } /// Frees a sq_revocation_status_t. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_revocation_status_free( rs: Option<&mut RevocationStatus>) { @@ -124,7 +124,7 @@ pub extern "system" fn sq_revocation_status_free( /* openpgp::Packet. */ /// Frees the Packet. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_packet_free(p: Option<&mut Packet>) { ffi_free!(p) } @@ -134,7 +134,7 @@ pub extern "system" fn sq_packet_free(p: Option<&mut Packet>) { /// Tags are explained in [Section 4.3 of RFC 4880]. /// /// [Section 4.3 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-4.3 -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_packet_tag(p: *const Packet) -> uint8_t { let p = ffi_param_ref!(p); @@ -149,7 +149,7 @@ pub extern "system" fn sq_packet_tag(p: *const Packet) /// Signature Packet uses some unsupported methods, it is parsed /// into an `Packet::Unknown`. `tag()` returns `SQ_TAG_SIGNATURE`, /// whereas `kind()` returns `0`. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_packet_kind(p: *const Packet) -> uint8_t { let p = ffi_param_ref!(p); @@ -161,13 +161,13 @@ pub extern "system" fn sq_packet_kind(p: *const Packet) } /// Frees the Signature. -#[no_mangle] +#[::ffi_catch_abort] #[no_mangle] pub extern "system" fn sq_signature_free(s: Option<&mut Signature>) |