Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

rc: fix /etc/TZ in Japan #1223

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

rc: fix /etc/TZ in Japan #1223

wants to merge 2 commits into from

Conversation

m-mishima
Copy link

little different "JST" at /etc/TZ in Japan

The "JST", select UTC in localtime();
Correctly, "JST-9" select JST in localtime();

$ echo "JST" > /etc/TZ; date
Sun Jan 29 10:00:49 UTC 2017
$ echo "JST-9" > /etc/TZ; date
Sun Jan 29 19:01:06 JST 2017

The "JST", select UTC in localtime();
Correctly, "JST-9" select JST in localtime();

$ echo "JST" > /etc/TZ; date
Sun Jan 29 10:00:49 UTC 2017
$ echo "JST-9" > /etc/TZ; date
Sun Jan 29 19:01:06 JST 2017
@RMerl
Copy link
Owner

RMerl commented Mar 1, 2017

I'm not sure I understand the idea of defining a -9 offset on top of what is already a UTC-9 offset.

Also, the use of strncpy() here is wrong, as strncpy will not null-terminate the string if the size is equal to the buffer length. That means whatever character is at the end of the buffer will be expected to be a string terminator - if it's not already a NULL, then your string will contain a lot of random data, which can lead to a crash.

@m-mishima
Copy link
Author

Thank you for your interest.

At least, ASUSROUTER now is not working in JST in Japan. It starts up as described in JST in /etc/TZ, but the date displayed in shell is UTC. This affects the behavior of cron. Cron refers to localtime(). In order to operate with JST, you need to include JST-9 in /etc/TZ.

WebUI has its own TIMEZONE correction. In this case, localtime() should not be used, and gmtime() should do its own correction after getting the UTC time.

Thank you for pointing out about strncpy(). tmpbuf Initialization was not done. I think that it should be initialized once with memset(), or quoted from neighboring code to sprintf().

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants