Bug 657570

Summary: strptime()'s '%b' descriptor should be greedy
Product: Red Hat Enterprise Linux 5 Reporter: Adrien Kunysz <akunysz>
Component: glibcAssignee: Andreas Schwab <schwab>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: medium Docs Contact:
Priority: low    
Version: 5.5CC: fweimer, goeran, iannis, jcastillo, mfranc, patrickm
Target Milestone: rc   
Target Release: 5.7   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glibc-2.5-67 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 657266 Environment:
Last Closed: 2012-02-21 06:32:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 657266, 657572    
Bug Blocks:    

Description Adrien Kunysz 2010-11-26 14:26:29 UTC
This is a request to backport the fix of Sourceware bz4773 in RHEL 5.

In RHEL5, the short month name for November in Finnish is not recognized by strptime(). This is due to upstream bug 4773. The test case developped for that bug can be easily adapted to the Finnish locale to show the problem as reported:

$ cat tst-strptime.c 
#define _XOPEN_SOURCE
#include <locale.h>
#include <time.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

int
main (void)
{
  if (setlocale (LC_ALL, "fi_FI.utf8") == NULL)
    {
      puts ("cannot set locale");
      return 1;
    }
  struct tm tm;
  static const char s[] = "marras";
  char *r = strptime (s, "%b", &tm);
  printf ("r = %p, r-s = %ju, tm.tm_mon = %d\n", r, (uintmax_t)(r - s), tm.tm_mon);
  return r == NULL || r - s != strlen(s) || tm.tm_mon != 10;
}
$ cc -std=gnu99 -o tst-strptime tst-strptime.c

On RHEL 5:

$ rpm -q glibc
glibc-2.5-42.el5_4.3
$ ./tst-strptime
r = 0x80485c3, r-s = 3, tm.tm_mon = 2
$ echo $?
1

On RHEL 6:

$ cc -Wall -W -pedantic -std=gnu99 -o tst-strptime tst-strptime.c 
$ ./tst-strptime 
r = 0x4007a1, r-s = 6, tm.tm_mon = 10
$ echo $?
0
$ rpm -q glibc
glibc-2.12-1.7.el6_0.3.x86_64
glibc-2.12-1.7.el6_0.3.i686

This was fixed upstream in commit f98c2d06bb4e04e59bb067b301bacf880fb72a9f. Test case was commited in 9ffe4385a8df731953e0857339ebc6dafea05570.
http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=9ffe4385a8df731953e0857339ebc6dafea05570
http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=f98c2d06bb4e04e59bb067b301bacf880fb72a9f
http://sources.redhat.com/bugzilla/show_bug.cgi?id=4773

Comment 2 RHEL Program Management 2011-06-20 22:19:04 UTC
This request was evaluated by Red Hat Product Management for inclusion in Red Hat Enterprise Linux 5.7 and Red Hat does not plan to fix this issue the currently developed update.

Contact your manager or support representative in case you need to escalate this bug.

Comment 5 errata-xmlrpc 2012-02-21 06:32:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0260.html