Re: [PATCH v2] add, rm, mv: fix bug that prevents the update of non-sparse dirs

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

 



On Tue, Oct 26, 2021 at 4:04 PM Derrick Stolee <stolee@xxxxxxxxx> wrote:
>
> On 10/26/2021 12:22 PM, René Scharfe wrote:
> >
> > slash can end up one less than path.  If path points to the first char
> > of a string object this would be undefined if I read 6.5.6 of C99
> > correctly.  (A pointer to the array element just after the last one is
> > specified as fine as long as it's not dereferenced, but a pointer to
> > the element before the first one is not mentioned and thus undefined.)
>
> I also see the specification saying this is undefined, but I do not
> understand how any reasonable compiler/runtime could do anything
> other than store "path - 1" as if it was an unsigned integer. There
> are a lot of references about "the array" that the pointer points to,
> but these pointer arithmetic things are not actually accessing the
> memory allocator.
>
> > Do you really need the ">=" instead of ">"?
>
> I think the only case that would be of any interest is if the path
> started with a slash, which would not be a valid worktree path.

Agreed.

> I believe we could use ">" for an abundance of caution with the
> undefined nature of subtracting from a pointer, but it is non-
> obvious that that is a real problem.

Yeah, I think it should be fine to use ">" to be extra careful.




[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