[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: %.1s format with vasnprintf reads more than one byte from argument
From: |
Eric Blake |
Subject: |
Re: %.1s format with vasnprintf reads more than one byte from argument |
Date: |
Wed, 25 Feb 2009 18:14:07 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Eric Blake <ebb9 <at> byu.net> writes:
> git reset --hard e8e63
> ./gnulib-tool --with-tests --test vasprintf-posix
>
> fails:
>
> ../../gltests/test-vasprintf-posix.c:3624: assertion failed
> Abort trap
> FAIL: test-vasprintf-posix
>
> In the debugger, I see that vasprintf(&result,"%.*ls",2,L"ab") is setting
> result to "a", not the expected "ab".
>
On OpenBSD, this results in vasnprintf trying to invoke the native:
retcount = snprintf(buffer,12,"%.*ls%n",2,L"ab",&count);
which sets buffer to "a", and retcount and count to 1, rather than the
expected "ab" and 2. Indeed, further stepping through the OpenBSD source code
shows that when precision is present, %.*ls uses memchr(arg,0,prec) to find
whether a terminating NUL is present, forgetting that it should instead be
looking for a terminating L'\0' and that the 8 bit '\0' found inside L'a' does
not count as the end of the wide string.
Looks like we need to add to the printf-posix.m4 tests to filter out this bug
in BSD %.*ls.
--
Eric Blake
- %.1s format with vasnprintf reads more than one byte from argument, Ben Pfaff, 2009/02/23
- Re: %.1s format with vasnprintf reads more than one byte from argument, Bruno Haible, 2009/02/23
- Re: %.1s format with vasnprintf reads more than one byte from argument, Ben Pfaff, 2009/02/23
- Re: %.1s format with vasnprintf reads more than one byte from argument, Eric Blake, 2009/02/25
- Re: %.1s format with vasnprintf reads more than one byte from argument, Eric Blake, 2009/02/26
- Re: %.1s format with vasnprintf reads more than one byte from argument, Bruno Haible, 2009/02/26
- Re: %.1s format with vasnprintf reads more than one byte from argument, Eric Blake, 2009/02/26
- Re: %.1s format with vasnprintf reads more than one byte from argument, Bruno Haible, 2009/02/27
- Re: %.1s format with vasnprintf reads more than one byte from argument, Eric Blake, 2009/02/27
- Re: %.1s format with vasnprintf reads more than one byte from argument, Eric Blake, 2009/02/27
- Re: %.1s format with vasnprintf reads more than one byte from argument, Eric Blake, 2009/02/27