From: Andreas Steffen Date: Thu, 28 Jul 2022 09:18:54 +0000 (+0200) Subject: pkcs7: Allow for missing optional content field X-Git-Tag: 5.9.8dr1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcedd65a31667a25427ad6f12ccdbf88d01af3a6;p=thirdparty%2Fstrongswan.git pkcs7: Allow for missing optional content field The content field of type OCTET STRING of a ContentInfo object with ContentType Data ContentInfo ::= SEQUENCE { contentType ContentType, content [0] EXPLICIT OCTET STRING OPTIONAL is optional and can be missing if no data is available --- diff --git a/src/libstrongswan/plugins/pkcs7/pkcs7_data.c b/src/libstrongswan/plugins/pkcs7/pkcs7_data.c index 235b9fe30a..98af138054 100644 --- a/src/libstrongswan/plugins/pkcs7/pkcs7_data.c +++ b/src/libstrongswan/plugins/pkcs7/pkcs7_data.c @@ -60,6 +60,13 @@ METHOD(container_t, get_data, bool, chunk_t chunk; chunk = this->content; + + /* The content field is optional */ + if (chunk.len == 0) + { + *data = chunk_empty; + return TRUE; + } if (asn1_unwrap(&chunk, &chunk) == ASN1_OCTET_STRING) { *data = chunk_clone(chunk);