Re: lsearch(3): memmove(3), not memcpy(3)

2021-12-06 Thread Todd C . Miller
On Mon, 06 Dec 2021 19:29:55 -0600, Scott Cheloha wrote: > This? I think this is fine. OK millert@ - todd

Re: lsearch(3): memmove(3), not memcpy(3)

2021-12-06 Thread Theo de Raadt
Scott Cheloha wrote: > On Mon, Dec 06, 2021 at 03:09:05PM -0700, Theo de Raadt wrote: > > +* Use memmove(3) instead of memcpy(3), just in case key > > +* partially overlaps with the end of the array. > > > > It isn't a "just in case", as in a possibility. > > ? > > > It is gaur

Re: lsearch(3): memmove(3), not memcpy(3)

2021-12-06 Thread Scott Cheloha
On Mon, Dec 06, 2021 at 03:09:05PM -0700, Theo de Raadt wrote: > +* Use memmove(3) instead of memcpy(3), just in case key > +* partially overlaps with the end of the array. > > It isn't a "just in case", as in a possibility. ? > It is gauranteed this condition will happen. I don

Re: lsearch(3): memmove(3), not memcpy(3)

2021-12-06 Thread Theo de Raadt
+* Use memmove(3) instead of memcpy(3), just in case key +* partially overlaps with the end of the array. It isn't a "just in case", as in a possibility. It is gauranteed this condition will happen. I don't like how these conditions are described as odd-cases, that isn't how mach

Re: lsearch(3): memmove(3), not memcpy(3)

2021-12-06 Thread Scott Cheloha
On Mon, Dec 06, 2021 at 01:47:52PM -0700, Todd C. Miller wrote: > On Mon, 06 Dec 2021 09:03:43 -0600, Scott Cheloha wrote: > > > In lsearch(3), the key is allowed to overlap with the last element in > > base. We need to memmove(3), not memcpy(3), or we could corrupt the > > key in that edge case.

Re: lsearch(3): memmove(3), not memcpy(3)

2021-12-06 Thread Todd C . Miller
On Mon, 06 Dec 2021 09:03:43 -0600, Scott Cheloha wrote: > In lsearch(3), the key is allowed to overlap with the last element in > base. We need to memmove(3), not memcpy(3), or we could corrupt the > key in that edge case. OK, but does this deserve a comment so to that effect to prevent someone

lsearch(3): memmove(3), not memcpy(3)

2021-12-06 Thread Scott Cheloha
In lsearch(3), the key is allowed to overlap with the last element in base. We need to memmove(3), not memcpy(3), or we could corrupt the key in that edge case. ok? Index: lsearch.c === RCS file: /cvs/src/lib/libc/stdlib/lsearch.c,v