Skip to content

Commit

Permalink
Initialise struct timezone (#1291)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wezm committed Aug 31, 2023
1 parent 6f18c09 commit 8e3a53e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ main_add_changes_commit(struct view *view, enum line_type type, const char *pare
struct graph *graph = state->graph;
struct commit commit = {{0}};
struct timeval now;
struct timezone tz;
struct timezone tz = {0};

if (!parent)
return true;
Expand Down

0 comments on commit 8e3a53e

Please sign in to comment.