Bug 77057 - Bad interaction between locale settings and the '%.*s' format specifier in the printf family
Bad interaction between locale settings and the '%.*s' format specifier in th...
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2002-10-31 10:34 EST by Need Real Name
Modified: 2016-11-24 10:17 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-10-31 10:35:52 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Simplistic testcase (299 bytes, patch)
2002-10-31 10:35 EST, Need Real Name
no flags Details | Diff

  None (edit)
Description Need Real Name 2002-10-31 10:34:48 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003

Description of problem:
If a program has used setlocale (LC_ALL, "") (as is typical for applications
using gettext), and $LANG is set to en_US (the default), using xxprintf ("blah
%.*s some more", <n>, <some string containing accented characters>) stops output
at the format spec.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. compile & run the attached C source
2. run the resulting program

Actual Results:  The accented string is printed only on the first time.

Expected Results:  The accented string is printed on both lines (this happens on
redhat 6.2 with glibc-2.2.4-5).

Additional info:

Any other setting than en_US seems to result in the correct behaviour, as does
omitting the setlocale() call (but the latter seems to be required for gettext()
to work).
Comment 1 Need Real Name 2002-10-31 10:35:46 EST
Created attachment 82884 [details]
Simplistic testcase
Comment 2 Jakub Jelinek 2002-11-01 15:35:48 EST
Cannot reproduce, works just fine with LANG=en_US and glibc 2.2.93-5
nor 2.3.1-2. Though LANG=en_US is certainly not the default in 8.0, it is
en_US.UTF-8, for which obviously the second printf stops at the format spec
because the string is not a valid UTF-8 string and thus printf cannot compute
its length.

Note You need to log in before you can comment on or make changes to this bug.