ASN1.y functions can't be used twice in a process due to global variables (also there is no thread-safety)

  • there is no global init (or deinit) function for libtasn1 to reset global variables after use
  • global variables are accessed without locking -> no thread-safety
  • calling asn1_parser2tree()/asn1_delete_structure() can only be done once due to global variable state
  • that means fuzzing with libFuzzer is currently now possible

Just for fuzzing, there is a simple solution: adding a asn1_global_init() function to set all global variables to default values.

There yacc options like %option reentrant. But I assume that we need a session struct and alloc/free functions to achieve parallel parser operations. I'm not deep enough into yacc/flex to quickly make this up.