aboutsummaryrefslogtreecommitdiff
path: root/lib/vtls/schannel_verify.c
diff options
context:
space:
mode:
authorDaniel Gustafsson <daniel@yesql.se>2018-10-03 00:56:29 +0200
committerDaniel Gustafsson <daniel@yesql.se>2018-10-03 23:45:38 +0200
commit2873971d6251b7c1eb278df1ee2b944d7c3fcdba (patch)
tree547fb9b9a1dcc8d9185c277d7c45ba746fad2fee /lib/vtls/schannel_verify.c
parente182fc1613196540df12bcaa846e79f80aa5432c (diff)
memory: ensure to check allocation results
The result of a memory allocation should always be checked, as we may run under memory pressure where even a small allocation can fail. This adds checking and error handling to a few cases where the allocation wasn't checked for success. In the ftp case, the freeing of the path variable is moved ahead of the allocation since there is little point in keeping it around across the strdup, and the separation makes for more readable code. In nwlib, the lock is aslo freed in the error path. Also bumps the copyright years on affected files. Closes #3084 Reviewed-by: Jay Satiro <raysatiro@yahoo.com> Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Diffstat (limited to 'lib/vtls/schannel_verify.c')
-rw-r--r--lib/vtls/schannel_verify.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/vtls/schannel_verify.c b/lib/vtls/schannel_verify.c
index cfc4adfe9..2516f5665 100644
--- a/lib/vtls/schannel_verify.c
+++ b/lib/vtls/schannel_verify.c
@@ -319,6 +319,10 @@ static CURLcode verify_host(struct Curl_easy *data,
* embedded null bytes. This appears to be undocumented behavior.
*/
cert_hostname_buff = (LPTSTR)malloc(len * sizeof(TCHAR));
+ if(!cert_hostname_buff) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto cleanup;
+ }
actual_len = CertGetNameString(pCertContextServer,
CERT_NAME_DNS_TYPE,
name_flags,