Re: [PATCH] Fix off by one error in prep_exclude.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Sun, 27 Jan 2008, Shawn Bohrer wrote:

> In "struct exclude_stack", prep_exclude() and excluded(), the
> convention for a path is to express the length of directory part
> including the trailing slash (e.g. "foo" and "bar/baz" will get
> baselen=0 and baselen=4 respectively).
> 
> The variable current and parameter baselen follow that
> convention in the codepath the following patch touches.
> 
>                 else {
>                         cp = strchr(base + current + 1, '/');
>                         if (!cp)
>                                 die("oops in prep_exclude");
>                         cp++;
>                 }
>                 stk->prev = dir->exclude_stack;
>                 stk->baselen = cp - base;
> 
> is about coming up with the next value for current (which is
> taken from stk->baselen) to dig one more level.
> 
> If base="foo/bar/boo" and current=4 (i.e. we are looking at
> "foo/"), the current code (base + current + 1) will begin scanning
> for the next slash at ar/boo skipping one letter ('b').  This
> patch starts the scanning at bar/boo/
> 
> This only causes a problem when a path component has a length of
> zero which can happen when the user provides an absolute path to
> a file or directory in the root directory (i.e. "/", or "/foo"),
> or if the input is malformed and contains a double-slash such
> as "foo//boo".
> 
> Signed-off-by: Shawn Bohrer <shawn.bohrer@xxxxxxxxx>

I'll try to remember even 6 months from now that this was the "git clean 
-n /" problem ;-)

Ciao,
Dscho
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux