[pacman-dev] [PATCH 2/2] Bail out on NULL destfile in curl_download_internal()

Lukas Fleischer archlinux at cryptocrack.de
Wed Aug 17 04:15:17 EDT 2011


Avoid a potential segfault that may occur if we use a temporary file and
fail to build the destination file name from the effective URL.

Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
---
Another approach is to use a random default destfile name. Since the URL
parsing is very unlikely to fail, I took the easy option here.

 lib/libalpm/dload.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 731d807..c552d2b 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -373,6 +373,11 @@ static int curl_download_internal(struct dload_payload *payload,
 				destfile = get_fullpath(localpath, effective_filename, "");
 			}
 		}
+		else {
+			_alpm_log(handle, ALPM_LOG_ERROR, _("could not parse file name from url (%s)"),
+					effective_url);
+			goto cleanup;
+		}
 	}
 
 	ret = 0;
-- 
1.7.6



More information about the pacman-dev mailing list