On Tue, 21 Sep 2010, Carlos R. Mafra wrote:

 > > --- a/WINGs/findfile.c
 > > +++ b/WINGs/findfile.c
 > > @@ -84,9 +84,8 @@ char *wexpandpath(char *path)
 > >            path++;
 > >            if (*path == '/' || *path == 0) {
 > >                    home = wgethomedir();
 > > -                  if (strlen(home) > PATH_MAX)
 > > +                  if (strlcpy(buffer, home, sizeof(buffer)) >= 
 > > sizeof(buffer))
 > >                            goto error;
 > > -                  strcat(buffer, home);
 > >            } else {
 > >                    int j;
 > >                    j = 0;
 > > @@ -98,9 +97,8 @@ char *wexpandpath(char *path)
 > >                            path++;
 > >                    }
 > >                    home = getuserhomedir(buffer2);
 > > -                  if (!home || strlen(home) > PATH_MAX)
 > > +                  if (!home || strlcat(buffer, home, sizeof(buffer)) >= 
 > > sizeof(buffer))
 > >                            goto error;
 > > -                  strcat(buffer, home);
 > 
 > I was wondering why you replaced the first strcat() with strlcpy() while
 > the second with strlcat(). 

it doesn't really matter. if you are just starting to fill up a 
storage, cat and cpy do the same thing. for consistency's sake i'll 
make them consistent, thanks for pointing it out.

 > > @@ -358,8 +370,11 @@ char *wfindfileinarray(WMPropList * array, char *file)
 > >            path = wmalloc(len + flen + 2);
 > >            path = memcpy(path, p, len);
 > >            path[len] = 0;
 > > -          strcat(path, "/");
 > > -          strcat(path, file);
 > > +          if (strlcat(path, "/", len + flen + 2) >= len + flen + 2 ||
 > > +              strlcat(path, file, len + flen + 2) >= len + flen + 2) {
 > > +                  wfree(path);
 > > +                  return NULL;
 > > +          }
 > 
 > Please put all these multiple "wfree(path); return NULL;" going into one
 > 'goto error', here and in other places in the patch too. You will also
 > save the { } for the if's, as they become one-liners.

thank you :) (lively demonstration of not all gotos are bad)

 > > +  for(i = 0; s[i]; !found && i++) {
 > 
 > 'for' is not a function, so for (...)

ok.

-- 
[-]

mkdir /nonexistent


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to