aboutsummaryrefslogtreecommitdiff
path: root/lib/vauth
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/vauth
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/vauth')
-rw-r--r--lib/vauth/digest.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/vauth/digest.c b/lib/vauth/digest.c
index fae5a4977..ab5156eb7 100644
--- a/lib/vauth/digest.c
+++ b/lib/vauth/digest.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -781,6 +781,8 @@ static CURLcode _Curl_auth_create_digest_http_message(
*/
hashthis = (unsigned char *) aprintf("%s:%s", request, uripath);
+ if(!hashthis)
+ return CURLE_OUT_OF_MEMORY;
if(digest->qop && strcasecompare(digest->qop, "auth-int")) {
/* We don't support auth-int for PUT or POST at the moment.