If the extension is invalid, the error code returned by ExtensionStructure() is FAILED_PRECONDITION, so the method continues until calling ext_struct.ValueOrDie(), resulting in a crash.
Originally, this check was !ext_struct.ok() || !ext_struct.ValueOrDie(), which correctly handled invalid extensions, but https://github.com/google/certificate-transparency/pull/949 changed this. Rather than just reverting this change, I've opted to:
Not re-introduce !ext_struct.ValueOrDie(), since the value should never be null if ext_struct.ok().
Return the actual status code returned by ExtensionStructure(), rather than just NOT_FOUND, since callers may actually be interested to know whether the extension was invalid.
If the extension is invalid, the error code returned by
ExtensionStructure()
isFAILED_PRECONDITION
, so the method continues until callingext_struct.ValueOrDie()
, resulting in a crash.Originally, this check was
!ext_struct.ok() || !ext_struct.ValueOrDie()
, which correctly handled invalid extensions, but https://github.com/google/certificate-transparency/pull/949 changed this. Rather than just reverting this change, I've opted to:!ext_struct.ValueOrDie()
, since the value should never be null if ext_struct.ok().