summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2011-08-17 16:45:35 +0200
committerDan McGee <dan@archlinux.org>2011-08-17 17:30:41 -0500
commit9cddc4ad80dbb52e30cdbcd168a4c19b73e30bbe (patch)
tree8c9db6092fb018a10bb86733559489ad91b23424 /lib
parent3ceef97799da9ec938dbade9e08e624ebb5fcea7 (diff)
downloadpacman-9cddc4ad80dbb52e30cdbcd168a4c19b73e30bbe.tar.xz
Skip rename() on NULL destfile in curl_download_internal()
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@cryptocrack.de> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/dload.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 9f1285d0..fd5c9289 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -385,12 +385,16 @@ cleanup:
}
if(ret == 0) {
- if(rename(tempfile, destfile)) {
- _alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
- tempfile, destfile, strerror(errno));
- ret = -1;
+ if (destfile) {
+ if(rename(tempfile, destfile)) {
+ _alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"),
+ tempfile, destfile, strerror(errno));
+ ret = -1;
+ } else if(final_file) {
+ *final_file = strdup(strrchr(destfile, '/') + 1);
+ }
} else if(final_file) {
- *final_file = strdup(strrchr(destfile, '/') + 1);
+ *final_file = strdup(strrchr(tempfile, '/') + 1);
}
}