Re: sed in CURRENT fails in textproc/jq

From: Robert Clausecker <fuz_at_fuz.su>
Date: Sun, 10 Sep 2023 13:36:26 UTC
Hi Warner,

I have pushed a fix.  It should hopefully address those failing tests.
The same issue should also affect memcmp(), but unlike for memchr(), it is
illegal to pass a length to memcmp() that extends past the actual end of
the buffer as memcmp() is permitted to examine the whole buffer regardless
of where the first mismatch is.

I am considering a change to improve the behaviour of memcmp() on such
errorneous inputs.  There are two options: (a) I could change memcmp() the
same way I fixed memchr() and have implausible buffer lengths behave as if
the buffer goes to the end of the address space or (b) I could change
memcmp() to crash loudly if it detects such a case.  I could also
(c) leave memcmp() as is.  Which of these three choices is preferable?

Yours,
Robert Clausecker

Am Sun, Sep 10, 2023 at 05:51:43AM -0600 schrieb Warner Losh:
> On Sat, Sep 9, 2023, 10:51 PM Robert Clausecker <fuz@fuz.su> wrote:
> 
> > Greetings,
> >
> > I apologise for the inconvenience.  The issue seems to boil down to
> > various places calling
> >
> >     memchr(buf, c, SIZE_MAX);
> >
> > which causes an overflow when my newly written memchr() computes buf +
> > len to find the end of the buffer.  A patch to alleviate this issue can
> > be found here:
> >
> >
> > http://fuz.su/~fuz/freebsd/0001-lib-libc-amd64-string-memchr.S-fix-behaviour-with-ov.patch
> >
> > Please check if it does the trick for you.  If yes, I'll go ahead and
> > push it tomorrow-ish.
> >
> 
> 
> There are half a dozen or do kyua tests that are likely failing because of
> this or other reasons related to strings.  When you push this fix you'll
> get the list. They are hidden among about 80 or so networking tests that
> fail. I plan on disabling those tests soon If no one fixes them.
> 
> Warner
> 
> >
> > Yours,
> > Robert Clausecker
> >
> > Am Sat, Sep 09, 2023 at 07:12:29PM +0200 schrieb Dag-Erling Smørgrav:
> > > Antoine Brodin <antoine@freebsd.org> writes:
> > > > Yuri <yuri@freebsd.org> writes:
> > > > > Either something has changed in sed(1) in CURRENT, or sed just fails
> > > > > during the configure stage of textproc/jq:
> > > > >
> > > > > sed: No error: 0
> > > > > checking for sys/cygwin.h... eval: ${+...}: Bad substitution
> > > > This seems to be a recent issue (less than 5 days).
> > > > Hundreds of configure scripts now fail to run on 15-current due to
> > > > this sed failure: [...]
> > >
> > > Try adding ARCHLEVEL=scalar to CONFIGURE_ENV on one of these.  If that
> > > helps, yell at fuz@ :)
> > >
> > > DES
> > > --
> > > Dag-Erling Smørgrav - des@FreeBSD.org
> > >
> >
> > --
> > ()  ascii ribbon campaign - for an 8-bit clean world
> > /\  - against html email  - against proprietary attachments
> >
> >

-- 
()  ascii ribbon campaign - for an 8-bit clean world 
/\  - against html email  - against proprietary attachments