libdnssec/key: bad logic leaves key with dangling pointer
How to reproduce:
-
a copy of binary data struct is made at L439
-
that struct is then resized to accomodate for new key. If successful,
new_rdata
points to resized memory,key->rdata
points to previous location. -
creating pubkey at L446 fails and function returns,
key->rdata
is still invalid -
further using key causes use-after-free, freeing double-free freeing key causes double-free and using it use-after-free