This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch][BZ 6530] *printf and incomplete multibyte sequencesreturns -1 bogusly


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]