1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

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>
This commit is contained in:
Lukas Fleischer 2011-08-17 16:45:35 +02:00 committed by Dan McGee
parent 3ceef97799
commit 9cddc4ad80

View File

@ -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);
}
}