]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fixup free in case of buffer short.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 10 Nov 2014 13:26:16 +0000 (13:26 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 10 Nov 2014 13:26:16 +0000 (13:26 +0000)
git-svn-id: file:///svn/unbound/trunk@3256 be551aaa-1e26-0410-a405-d3ace91eadb9

ldns/keyraw.c

index fe650aadacb314595ca4e0766d875a89169c3e8c..1ff07742b8808c6e538e3e0d6eecfbfbf1b405c6 100644 (file)
@@ -324,8 +324,10 @@ sldns_ecdsa2pkey_raw(unsigned char* key, size_t keylen, uint8_t algo)
                 ec = EC_KEY_new_by_curve_name(NID_secp384r1);
         } else    ec = NULL;
         if(!ec) return NULL;
-       if(keylen+1 > sizeof(buf))
-               return NULL; /* sanity check */
+       if(keylen+1 > sizeof(buf)) { /* sanity check */
+                EC_KEY_free(ec);
+               return NULL;
+       }
        /* prepend the 0x02 (from docs) (or actually 0x04 from implementation
         * of openssl) for uncompressed data */
        buf[0] = POINT_CONVERSION_UNCOMPRESSED;