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:
parent
3ceef97799
commit
9cddc4ad80
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user