pub fn strip_cbor_metadata(code: &[u8]) -> (Vec<u8>, Option<SolcVersion>)Expand description
Strip the trailing solc CBOR metadata tail.
The tail is <cbor body> <u16-BE body length>. Solc emits the
"solc": <3-byte version> map entry last, so a genuine body ends with
64 "solc" 43 <ver>. The body length is bounded (51 bytes with the default
ipfs entry); a larger claimed length is treated as code, not metadata, so an
attacker cannot hide appended bytes under an oversized tail.
Without a valid tail the input is returned unchanged with None.