Bug 1503452

Summary: timedatectl crashes if the length of the day name in the current locale is long
Product: [Fedora] Fedora Reporter: Hedayat Vatankhah <hedayatv>
Component: systemdAssignee: Zbigniew Jędrzejewski-Szmek <zbyszek>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 27CC: harald, jsynacek, kay, lnykryn, lpoetter, mschmidt, msekleta, ssahani, s, systemd-maint, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemd-236-1.fc28 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1503942 (view as bug list) Environment:
Last Closed: 2018-01-11 10:05:32 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:    
Bug Blocks: 1503942    

Description Hedayat Vatankhah 2017-10-18 07:27:23 UTC
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

Comment 1 Jan Synacek 2017-10-18 07:41:44 UTC
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.

Comment 2 Zbigniew Jędrzejewski-Szmek 2017-10-18 14:32:23 UTC
https://github.com/systemd/systemd/pull/7123

Comment 3 Jan Synacek 2017-10-19 06:59:27 UTC
Nice, thanks for the fast fix!