diff options
Diffstat (limited to 'lib/x509/pkcs7.c')
-rw-r--r-- | lib/x509/pkcs7.c | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/lib/x509/pkcs7.c b/lib/x509/pkcs7.c index 8f7d759107..4bf30284ef 100644 --- a/lib/x509/pkcs7.c +++ b/lib/x509/pkcs7.c @@ -173,7 +173,13 @@ int gnutls_pkcs7_get_certificate(gnutls_pkcs7 pkcs7, return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; } - tmp_size = 256; /* some initial size */ + tmp_size = 0; + result = asn1_read_value(pkcs7->pkcs7, "content", NULL, &tmp_size); + if (result!=ASN1_MEM_ERROR) { + gnutls_assert(); + return _gnutls_asn2err(result); + } + tmp = gnutls_malloc(tmp_size); if (tmp==NULL) { gnutls_assert(); @@ -181,17 +187,6 @@ int gnutls_pkcs7_get_certificate(gnutls_pkcs7 pkcs7, } result = asn1_read_value(pkcs7->pkcs7, "content", tmp, &tmp_size); - /* FIXME: a hard coded value - */ - if (result==ASN1_MEM_ERROR && tmp_size > 0 && tmp_size < 50*1024) { - tmp = gnutls_realloc_fast( tmp, tmp_size); - if (tmp==NULL) { - gnutls_assert(); - return GNUTLS_E_MEMORY_ERROR; - } - result = asn1_read_value(pkcs7->pkcs7, "content", tmp, &tmp_size); - } - if (result != ASN1_SUCCESS) { gnutls_assert(); result = _gnutls_asn2err(result); @@ -313,7 +308,13 @@ int gnutls_pkcs7_get_certificate_count(gnutls_pkcs7 pkcs7) return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; } - tmp_size = 256; /* some initial size */ + tmp_size = 0; + result = asn1_read_value(pkcs7->pkcs7, "content", NULL, &tmp_size); + if (result!=ASN1_MEM_ERROR) { + gnutls_assert(); + return _gnutls_asn2err(result); + } + tmp = gnutls_malloc(tmp_size); if (tmp==NULL) { gnutls_assert(); @@ -321,18 +322,7 @@ int gnutls_pkcs7_get_certificate_count(gnutls_pkcs7 pkcs7) } result = asn1_read_value(pkcs7->pkcs7, "content", tmp, &tmp_size); - /* FIXME: a hard coded value - */ - if (result==ASN1_MEM_ERROR && tmp_size > 0 && tmp_size < 50*1024) { - tmp = gnutls_realloc_fast( tmp, tmp_size); - if (tmp==NULL) { - gnutls_assert(); - return GNUTLS_E_MEMORY_ERROR; - } - result = asn1_read_value(pkcs7->pkcs7, "content", tmp, &tmp_size); - } - - if (result != ASN1_SUCCESS) { + if (result!=ASN1_SUCCESS) { gnutls_assert(); result = _gnutls_asn2err(result); goto cleanup; |