From 7cd8010d65cfb4370037baad4e8fc0401ba0bff3 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sun, 22 Jun 2025 10:00:11 +1000 Subject: [PATCH] Adjust PATH_MAX length tests using snprintf The return value for snprintf does not include the null delimiter. So tests for path length should use use '>= PATH_MAX'. Signed-off-by: Allan McRae --- src/pacman/sync.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pacman/sync.c b/src/pacman/sync.c index a3797e85..e1980750 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -84,7 +84,7 @@ static int sync_cleandb(const char *dbpath) /* build the full path */ len = snprintf(path, PATH_MAX, "%s%s", dbpath, dname); - if(len > PATH_MAX) { + if(len >= PATH_MAX) { pm_printf(ALPM_LOG_ERROR, _("could not remove %s%s: path exceeds PATH_MAX\n"), dbpath, dname); } @@ -245,7 +245,7 @@ static int sync_cleancache(int level) /* build the full filepath */ len=snprintf(path, PATH_MAX, "%s%s", cachedir, ent->d_name); - if(len > PATH_MAX) { + if(len >= PATH_MAX) { pm_printf(ALPM_LOG_ERROR, _("skipping %s%s: path exceeds PATH_MAX\n"), cachedir, ent->d_name); continue;