This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [Patch][BZ 6530] *printf and incomplete multibyte sequencesreturns -1 bogusly
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: Jeff Law <law at redhat dot com>
- Cc: libc-alpha <libc-alpha at sourceware dot org>
- Date: Tue, 2 Oct 2012 02:33:48 -0400
- Subject: Re: [Patch][BZ 6530] *printf and incomplete multibyte sequencesreturns -1 bogusly
- References: <506A03F6.8020202@redhat.com>
On Mon, Oct 1, 2012 at 4:58 PM, Jeff Law <law@redhat.com> wrote:
> Attached is the patch I checked in to fix BZ 6530.
>
> As mentioned in the BZ, comment #6 C99 conformance demands:
>
> If no l length modifier is present, the argument shall be a pointer to the
> initial element of an array of character type.246) [...] If an l length
> modifier is present, the argument shall be a pointer to the initial element
> of an array of wchar_t type.
>
> 246) No special provisions are made for multibyte characters.
>
> So a format string such as %.50s, the string must be treated as an array of
> chars. Returning an error because the string isn't a valid UTF-8 sequence
> isn't right according to the standard.
>
> The patch simply removes the unwanted code which tried to treat the string
> like multibyte chars. The patch to remove the unwanted code is originally
> from Andreas Schwab and we've been using it to avoid this problem in Fedora
> for about two years now.
>
> Jonathan Nieder cobbled together the necessary changes to the testsuite to
> test for this problem.
>
> All I've done is combine those two changes into a single patch along with
> the usual NEWS update.
>
> I verified that Jonathan's test fails when installed without Andreas's patch
> and that after Andreas's patch the test succeeds. I observed no regressions
> when testing.
Thanks for posting this to the list!
It's good practice and gives people a final chance to comment.
The patch looks OK to me, but I haven't thought deeply about the conditions
under which the original code would have been useful.
Thanks for pushing this particular issue to completion.
Cheers,
Carlos.