]> granicus.if.org Git - curl/commitdiff
x509asn1: return CURLE_PEER_FAILED_VERIFICATION on failure to parse cert
authorHan Han <hhan@thousandeyes.com>
Mon, 20 Aug 2018 22:10:40 +0000 (15:10 -0700)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 6 Sep 2018 06:27:15 +0000 (08:27 +0200)
CURLE_PEER_FAILED_VERIFICATION makes more sense because Curl_parseX509
does not allocate memory internally as its first argument is a pointer
to the certificate structure. The same error code is also returned by
Curl_verifyhost when its call to Curl_parseX509 fails so the change
makes error handling more consistent.

lib/x509asn1.c

index 72a0b4a0002bcefc858569f73e357054020f9538..fc51e02f4ef7342837d8273b9efe4d999db2ce2c 100644 (file)
@@ -896,7 +896,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn,
 
   /* Extract the certificate ASN.1 elements. */
   if(Curl_parseX509(&cert, beg, end))
-    return CURLE_OUT_OF_MEMORY;
+    return CURLE_PEER_FAILED_VERIFICATION;
 
   /* Subject. */
   ccp = DNtostr(&cert.subject);