Azure / iot-identity-service

Source of the Azure IoT Identity Service and related services.
MIT License
37 stars 46 forks source link

Fix nullptr deref when decoding EST PKCS#7 response. #568

Closed arsing closed 11 months ago

arsing commented 12 months ago

Cherry-pick from main of 7482a00c0a18ae4e7cfcdefcdde4a0c195b94268

The original code did not handle two cases of nullptr deref when parsing an EST server's PKCS#7 response:

  1. If the PKCS#7 blob was not of "signed" type, then aziot_certd_pkcs7_to_x509 would return NULL and the Rust caller would deref it regardless.

  2. If the PKCS#7 blob was of "signed" type but its d.sign pointer was NULL, the C code would deref it regardless.

Also, openssl-sys does have bindings for the related types now, so the code can be written in Rust instead of C.

So this change moves that code from C to Rust and fixes the two derefs.