The string only becomes longer than PATH_MAX once adding "/" to the end. The error message should give this version of the path. Signed-off-by: morganamilo <morganamilo@gmail.com> diff --git a/src/pacman/query.c b/src/pacman/query.c index a1197cea..ecf8d148 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -207,15 +207,15 @@ static int query_fileowner(alpm_list_t *targets) rel_path = rpath + rootlen; if((is_missing && is_dir) || (!is_missing && (is_dir = S_ISDIR(buf.st_mode)))) { - if(rlen + 2 >= PATH_MAX) { - pm_printf(ALPM_LOG_ERROR, _("path too long: %s/\n"), rpath); - goto targcleanup; - } if ((rpathsave = realloc(rpath, rlen + 2)) == NULL) { goto targcleanup; } rpath = rpathsave; strcat(rpath + rlen, "/"); + if(rlen + 2 >= PATH_MAX) { + pm_printf(ALPM_LOG_ERROR, _("path too long: %s/\n"), rpath); + goto targcleanup; + } } for(i = packages; i && (!found || is_dir); i = alpm_list_next(i)) { -- 2.19.0