Re: [pacman-dev] [PATCH 2/2] pacman: give path too long error after strcat

2018-09-22 Thread Morgan Adamiec
On Sat, 22 Sep 2018 at 21:54, Andrew Gregory  wrote:
>
> 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 
>
> 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

Oh yeah silly me, missed the / inside the printf. Disregard this patch then.


Re: [pacman-dev] [PATCH 2/2] pacman: give path too long error after strcat

2018-09-22 Thread Andrew Gregory
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 

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


[pacman-dev] [PATCH 2/2] pacman: give path too long error after strcat

2018-09-22 Thread morganamilo
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 

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