summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2014-05-22 13:35:22 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2014-05-22 13:36:13 +0200
commit0a13bc02e5f613dd7fba9eabf73192003e0fcc0d (patch)
tree3fef27221eb8828247dbb33486d70a7ab0df014e
parent9375ae2c131df748929275d58e18c9792a55a403 (diff)
downloadgnutls-0a13bc02e5f613dd7fba9eabf73192003e0fcc0d.tar.gz
gnutls_x509_crt_get_extension_data: will return zero if data is NULL and memory buffer size is not sufficient.
-rw-r--r--lib/x509/x509.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/x509/x509.c b/lib/x509/x509.c
index f84d29a22f..c52feb8f8a 100644
--- a/lib/x509/x509.c
+++ b/lib/x509/x509.c
@@ -2217,7 +2217,7 @@ gnutls_x509_crt_get_extension_info(gnutls_x509_crt_t cert, int indx,
* @cert: should contain a #gnutls_x509_crt_t structure
* @indx: Specifies which extension OID to send. Use (0) to get the first one.
* @data: a pointer to a structure to hold the data (may be null)
- * @sizeof_data: initially holds the size of @oid
+ * @sizeof_data: initially holds the size of @data
*
* This function will return the requested extension data in the
* certificate. The extension data will be stored as a string in the
@@ -2252,9 +2252,14 @@ gnutls_x509_crt_get_extension_data(gnutls_x509_crt_t cert, int indx,
result = asn1_read_value(cert->cert, name, data, &len);
*sizeof_data = len;
- if (result == ASN1_ELEMENT_NOT_FOUND)
+ if (result == ASN1_ELEMENT_NOT_FOUND) {
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
- else if (result != ASN1_SUCCESS) {
+ } else if (result == ASN1_MEM_ERROR && data == NULL) {
+ /* normally we should return GNUTLS_E_SHORT_MEMORY_BUFFER,
+ * but we haven't done that for long time, so use
+ * backwards compatible behavior */
+ return 0;
+ } else if (result != ASN1_SUCCESS) {
gnutls_assert();
return _gnutls_asn2err(result);
}