[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 102/116: metalink: fix memory-leak and NULL pointer
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 102/116: metalink: fix memory-leak and NULL pointer dereference |
Date: |
Tue, 05 Dec 2017 14:52:12 +0100 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit d6ec96f7ffc5e8ee264d206634d3ec146794b80b
Author: Daniel Stenberg <address@hidden>
AuthorDate: Fri Nov 24 09:02:54 2017 +0100
metalink: fix memory-leak and NULL pointer dereference
Reported by scan-build
Closes #2109
---
src/tool_metalink.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/tool_metalink.c b/src/tool_metalink.c
index 270345547..bbbfc2a65 100644
--- a/src/tool_metalink.c
+++ b/src/tool_metalink.c
@@ -539,6 +539,7 @@ digest_context *Curl_digest_init(const digest_params
*dparams)
ctxt->digest_hash = dparams;
if(dparams->digest_init(ctxt->digest_hashctx) != 1) {
+ free(ctxt->digest_hashctx);
free(ctxt);
return NULL;
}
@@ -557,7 +558,8 @@ int Curl_digest_update(digest_context *context,
int Curl_digest_final(digest_context *context, unsigned char *result)
{
- (*context->digest_hash->digest_final)(result, context->digest_hashctx);
+ if(result)
+ (*context->digest_hash->digest_final)(result, context->digest_hashctx);
free(context->digest_hashctx);
free(context);
@@ -622,6 +624,7 @@ static int check_hash(const char *filename,
result = malloc(digest_def->dparams->digest_resultlen);
if(!result) {
close(fd);
+ Curl_digest_final(dctx, NULL);
return -1;
}
while(1) {
@@ -690,6 +693,8 @@ static metalink_checksum
*new_metalink_checksum_from_hex_digest
chksum->digest_def = digest_def;
chksum->digest = digest;
}
+ else
+ free(digest);
return chksum;
}
@@ -781,8 +786,24 @@ static metalinkfile *new_metalinkfile(metalink_file_t
*fileinfo)
curl_strequal((*p)->type, "ftp") ||
curl_strequal((*p)->type, "ftps")) {
res = new_metalink_resource((*p)->url);
- tail->next = res;
- tail = res;
+ if(res) {
+ tail->next = res;
+ tail = res;
+ }
+ else {
+ tail = root.next;
+
+ /* clean up the linked list */
+ while(tail) {
+ res = tail->next;
+ free(tail->url);
+ free(tail);
+ tail = res;
+ }
+ free(f->filename);
+ free(f);
+ return NULL;
+ }
}
}
f->resource = root.next;
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 93/116: http2: fix "Value stored to 'end' is never read" scan-build error, (continued)
- [GNUnet-SVN] [gnurl] 93/116: http2: fix "Value stored to 'end' is never read" scan-build error, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 94/116: Curl_open: fix OOM return error correctly, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 113/116: openssl: fix boringssl build again, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 110/116: global_init: ignore CURL_GLOBAL_SSL's absense, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 114/116: THANKS: added contributors from 7.57.0 release, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 88/116: ntlm: remove unnecessary NULL-check to please scan-build, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 112/116: curl_ntlm_core.c: use the limits.h's SIZE_T_MAX if provided, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 107/116: url: fix alignment of ssl_backend_data struct, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 116/116: Merge tag 'curl-7_57_0', gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 111/116: libcurl-share.3: the connection cache is shareable now, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 102/116: metalink: fix memory-leak and NULL pointer dereference,
gnunet <=
- [GNUnet-SVN] [gnurl] 109/116: ntlm: avoid integer overflow for malloc size, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 115/116: RELEASE-NOTES: curl 7.57.0, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 104/116: test: add tests to ensure basic file: URLs, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 100/116: make: fix "make distclean", gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 90/116: mime: fix "Value stored to 'sz' is never read" scan-build error, gnunet, 2017/12/05
- [GNUnet-SVN] [gnurl] 74/116: setopt: split out curl_easy_setopt() to its own file, gnunet, 2017/12/05