[pacman-dev] [PATCH 2/2] pacman: give path too long error after strcat
Andrew Gregory
andrew.gregory.8 at gmail.com
Sat Sep 22 20:54:24 UTC 2018
On 09/22/18 at 09:16pm, morganamilo wrote:
> 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 at gmail.com>
NACK. The trailing slash is in the format string; your version now
has two trailing slashes..
> 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
More information about the pacman-dev
mailing list