4 ms·
Clearly Rust can't solve all bugs, but I bet it would have prevented this one. GENERAL_NAME[1] is a struct containing a type tag "enum" and a union of the data
by azdle 6y ago
Clearly Rust can't solve all bugs, but I bet it would have prevented this one.
GENERAL_NAME[1] is a struct containing a type tag "enum" and a union of the data (d) for each type. If I'm reading it right the bug here is reading the union as 'other' when the tag says its `GEN_EDIPARTY`.
In rust this would just be a fat enum where the variants of the enum would actually contain the data that this has in the union. Then the Rust compiler would only allow you to read the data as the type it's stored as.
[1] https://github.com/openssl/openssl/blob/13a574d8bb2523181f8150de49bc041c9841f59d/include/openssl/x509v3.h.in#L137-L167 https://github.com/openssl/openssl/blob/13a574d8bb2523181f81...