index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Eli Schwartz <eschwartz@archlinux.org> | 2018-05-11 13:59:26 -0400 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2018-05-12 21:36:35 +1000 |
commit | af6125fbcc51b2074321003c3cbd74aeb65d9b7b (patch) | |
tree | dbf4a445db1670c21d7c3d42fc90c643fb52a016 | |
parent | 0d356c27c17fb62ed31327d634748f64c781dc49 (diff) |
-rw-r--r-- | lib/libalpm/remove.c | 16 |
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index a83710ed..8b92a084 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -404,14 +404,22 @@ static void shift_pacsave(alpm_handle_t *handle, const char *file) /* Shift pacsaves */ unsigned long i; for(i = log_max + 1; i > 1; i--) { - snprintf(oldfile, PATH_MAX, "%s.pacsave.%lu", file, i-1); - snprintf(newfile, PATH_MAX, "%s.pacsave.%lu", file, i); + if(snprintf(oldfile, PATH_MAX, "%s.pacsave.%lu", file, i-1) >= PATH_MAX + || snprintf(newfile, PATH_MAX, "%s.pacsave.%lu", file, i) >= PATH_MAX) { + _alpm_log(handle, ALPM_LOG_ERROR, + _("could not backup %s due to PATH_MAX overflow\n"), file); + goto cleanup; + } rename(oldfile, newfile); } - snprintf(oldfile, PATH_MAX, "%s.pacsave", file); + if(snprintf(oldfile, PATH_MAX, "%s.pacsave", file) >= PATH_MAX + || snprintf(newfile, PATH_MAX, "%s.1", oldfile) >= PATH_MAX) { + _alpm_log(handle, ALPM_LOG_ERROR, + _("could not backup %s due to PATH_MAX overflow\n"), file); + goto cleanup; + } if(stat(oldfile, &st) == 0) { - snprintf(newfile, PATH_MAX, "%s.1", oldfile); rename(oldfile, newfile); } |