Skip to content

Initialise struct timezone in main_add_changes_commit#1291

Merged
koutcher merged 1 commit intojonas:masterfrom
wezm:gettimeofday
Aug 31, 2023
Merged

Initialise struct timezone in main_add_changes_commit#1291
koutcher merged 1 commit intojonas:masterfrom
wezm:gettimeofday

Conversation

@wezm
Copy link
Copy Markdown
Contributor

@wezm wezm commented Aug 1, 2023

On musl libc gettimeofday (which is used by time_now) does not populate the timezone struct passed to it as POSIX says:

If tzp is not a null pointer, the behavior is unspecified.

tz_minuteswest is later multiplied by 60 which can overflow (if the value that happens to be in tz_minuteswest is large). When tig is compiled with integer overflow hardening (as is done on Chimera Linux) via the clang option -fsanitize=signed-integer-overflow this can result in tig crashing due to the overflow.

This PR initialises tz to prevent this.

On musl libc gettimeofday (which is used by time_now) does not
populate the timezone struct passed to it as POSIX says:

> If tzp is not a null pointer, the behavior is unspecified.

tz_minuteswest is later multiplied by 60 which can overflow. When tig
is compiled with integer overflow hardening (as is done on Chimera
Linux) via the clang option -fsanitize=signed-integer-overflow this can
result in tig crashing due to the overflow.
@koutcher
Copy link
Copy Markdown
Collaborator

LGTM, thanks

@koutcher koutcher merged commit 8e3a53e into jonas:master Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants