Bug 1503942

Summary: timedatectl crashes if the length of the day name in the current locale is long
Product: Red Hat Enterprise Linux 7 Reporter: Jan Synacek <jsynacek>
Component: systemdAssignee: Jan Synacek <jsynacek>
Status: CLOSED ERRATA QA Contact: Frantisek Sumsal <fsumsal>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: fsumsal, ovasik, rskvaril, systemd-maint-list
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemd-219-47.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1503452 Environment:
Last Closed: 2018-04-10 11:24:09 UTC Type: Bug
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: 1503452    
Bug Blocks:    

Description Jan Synacek 2017-10-19 07:03:18 UTC
+++ This bug was initially created as a clone of Bug #1503452 +++

Description of problem:
Crash in the last command:


% export LANG=en_US.UTF-8
[hedayat@hv ~]% date
Wed Oct 18 10:54:07 +0330 2017
[hedayat@hv ~]% timedatectl
      Local time: Wed 2017-10-18 11:24:10 +0400
  Universal time: Wed 2017-10-18 07:24:10 UTC
        RTC time: Wed 2017-10-18 07:24:10
       Time zone: Asia/Folan (+0400, +0400)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no
[hedayat@hv ~]% 
[hedayat@hv ~]% export LANG=fa_IR.UTF-8
[hedayat@hv ~]% date
چهارشنبه ۱۸ اكتبر ۱۷، ساعت ۱۰:۵۴:۲۴ (+0330)
[hedayat@hv ~]% timedatectl            
Assertion 'xstrftime: a[] must be big enough' failed at ../src/timedate/timedatectl.c:105, function print_status_info(). Aborting.
zsh: abort (core dumped)  timedatectl


Version-Release number of selected component (if applicable):
systemd-234-8.fc27.x86_64

How reproducible:
Depends on the current day of week. Happens on Wednesdays & Thursdays in fa_IR locale

--- Additional comment from Jan Synacek on 2017-10-18 09:41:44 CEST ---

src/basic/time-util.h:75:#define FORMAT_TIMESTAMP_MAX (3+1+10+1+8+1+6+1+6+1)
src/timedate/timedatectl.c:75:        char a[FORMAT_TIMESTAMP_MAX];
src/timedate/timedatectl.c:105                 xstrftime(a, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&sec, &tm));

It seems that the maximum format length assumption only holds for non-wide/variable encoded characters.

--- Additional comment from Zbigniew Jędrzejewski-Szmek on 2017-10-18 16:32:23 CEST ---

https://github.com/systemd/systemd/pull/7123

Comment 1 Jan Synacek 2017-10-19 08:01:03 UTC
Note that using the same reproducer as in the original bug report didn't reproduce the problem for me. It should be fixed anyway, as the assumption in the code is simply wrong.

Comment 2 Jan Synacek 2017-10-24 12:49:00 UTC
https://github.com/lnykryn/systemd-rhel/pull/165

Comment 4 Lukáš Nykrýn 2017-11-13 14:20:17 UTC
fix merged to staging branch -> https://github.com/lnykryn/systemd-rhel/pull/165 -> post

Comment 10 errata-xmlrpc 2018-04-10 11:24:09 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.

https://access.redhat.com/errata/RHBA-2018:0711