diff options
author | Nikos <nmav@crystal.(none)> | 2008-04-10 21:20:18 +0300 |
---|---|---|
committer | Nikos <nmav@crystal.(none)> | 2008-04-10 21:20:18 +0300 |
commit | eba903739ba734954b290ec8465da99d155e2506 (patch) | |
tree | 0fa8bef653ccac141e1f73ef683efd5db18570f5 /lib/openpgp | |
parent | 110570ed572338e63ada7ad06b1b40e048b98041 (diff) | |
download | gnutls-eba903739ba734954b290ec8465da99d155e2506.tar.gz |
corrected bug in openpgp import when data is of size zero. Reported by
Daniel Kahn
Diffstat (limited to 'lib/openpgp')
-rw-r--r-- | lib/openpgp/extras.c | 6 | ||||
-rw-r--r-- | lib/openpgp/pgp.c | 8 | ||||
-rw-r--r-- | lib/openpgp/privkey.c | 6 |
3 files changed, 19 insertions, 1 deletions
diff --git a/lib/openpgp/extras.c b/lib/openpgp/extras.c index 54b3c9ab12..56ff449c19 100644 --- a/lib/openpgp/extras.c +++ b/lib/openpgp/extras.c @@ -133,6 +133,12 @@ gnutls_openpgp_keyring_import (gnutls_openpgp_keyring_t keyring, size_t raw_len = 0; opaque *raw_data = NULL; + if (data->data == NULL || data->size == 0) + { + gnutls_assert(); + return GNUTLS_E_OPENPGP_GETKEY_FAILED; + } + _gnutls_debug_log ("PGP: keyring import format '%s'\n", format == GNUTLS_OPENPGP_FMT_RAW ? "raw" : "base64"); diff --git a/lib/openpgp/pgp.c b/lib/openpgp/pgp.c index 2c085b1bfa..09402ebd59 100644 --- a/lib/openpgp/pgp.c +++ b/lib/openpgp/pgp.c @@ -92,7 +92,13 @@ gnutls_openpgp_crt_import (gnutls_openpgp_crt_t key, cdk_stream_t inp; cdk_packet_t pkt; int rc; - + + if (data->data == NULL || data->size == 0) + { + gnutls_assert(); + return GNUTLS_E_OPENPGP_GETKEY_FAILED; + } + if (format == GNUTLS_OPENPGP_FMT_RAW) rc = cdk_kbnode_read_from_mem (&key->knode, data->data, data->size); else diff --git a/lib/openpgp/privkey.c b/lib/openpgp/privkey.c index 57d034223e..695346b25e 100644 --- a/lib/openpgp/privkey.c +++ b/lib/openpgp/privkey.c @@ -96,6 +96,12 @@ gnutls_openpgp_privkey_import (gnutls_openpgp_privkey_t key, cdk_stream_t inp; cdk_packet_t pkt; int rc; + + if (data->data == NULL || data->size == 0) + { + gnutls_assert(); + return GNUTLS_E_OPENPGP_GETKEY_FAILED; + } if (format == GNUTLS_OPENPGP_FMT_RAW) rc = cdk_kbnode_read_from_mem (&key->knode, data->data, data->size); |