Re: write past end of buffer in vasnprintf() implementation of %f

2018-10-02 Thread Bruno Haible
> + for (size = 0; size <= 8; size++) > +{ > + size_t length; > + char *result; > + > + memcpy (buf, "DEADBEEF", 8); > + length = size; > + result = my_asnprintf (buf, &length, "%2.0f", 1.6314159265358979e+125); > + ASSERT (result != NULL); > + ASSERT (strcmp

Re: write past end of buffer in vasnprintf() implementation of %f

2018-09-23 Thread Ben Pfaff
On Sun, Sep 23, 2018 at 02:25:50PM +0200, Bruno Haible wrote: > > The line in convert_to_decimal() cited above is the assignment here: > > > > /* Terminate the string. */ > > *d_ptr = '\0'; > > > > I guess that the space calculation passed to malloc() at the top of the > > same funct

Re: write past end of buffer in vasnprintf() implementation of %f

2018-09-23 Thread Bruno Haible
Ben Pfaff wrote: > CC='gcc -fsanitize=address -g -O0' ./gnulib-tool --test vasnprintf > vasnprintf-posix A couple of notes about this report: 1) The -O0 in the above command is ineffective. Reason: CFLAGS is '-O2 -g' by default, thus when a file gets compiled by $CC $CFLAGS, the -O2 always

Re: write past end of buffer in vasnprintf() implementation of %f

2018-09-23 Thread Bruno Haible
Hi Ben, > When I apply the following patch to gnulib: > > -- > diff --git a/tests/test-vasnprintf.c b/tests/test-vasnprintf.c > index 19731bc93378..105ac24c94a3 100644 > --- a/tests/test-vasnprintf.c > +++ b/tests/test-vasnprintf