Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/remove.c16
1 files changed, 12 insertions, 4 deletions
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);
}