parse_sigtype() only subtracted the length of "<type>$" from the signature size, not the full "$PKGSIGN:<type>$" marker, so read_pubkey() copied 9 bytes past the end of the signature buffer into the signature. The ECC signer happened to tolerate this because its DER parser ignores trailing bytes, but a signer that checks the signature length exactly will reject every typed pubkey signature.
Also search for the closing '$' with memchr() bounded by the buffer length rather than relying on the buffer being NUL-terminated.
While here, drop an unneeded __DECONST: BIO_new_mem_buf() takes a const pointer.
Fixes: 3d0a0dda3a7d ("pkg: finish adding the ECC signer and signature type bits")