Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1808,17 +1808,18 @@ init_timezone(PyObject *m)
julyzone_t = -get_gmtoff(t, &p);
julyname[9] = '\0';

int janzone = (int)janzone_t;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add a comment explaining this cast: mention unsigned time_t, maybe QNX, and the issue number.

I would feel more comfortable with int64_t type instead of int.

int julyzone = (int)julyzone_t;

/* Sanity check, don't check for the validity of timezones.
In practice, it should be more in range -12 hours .. +14 hours. */
#define MAX_TIMEZONE (48 * 3600)
if (janzone_t < -MAX_TIMEZONE || janzone_t > MAX_TIMEZONE
|| julyzone_t < -MAX_TIMEZONE || julyzone_t > MAX_TIMEZONE)
if (janzone < -MAX_TIMEZONE || janzone > MAX_TIMEZONE
|| julyzone < -MAX_TIMEZONE || julyzone > MAX_TIMEZONE)
{
PyErr_SetString(PyExc_RuntimeError, "invalid GMT offset");
return -1;
}
int janzone = (int)janzone_t;
int julyzone = (int)julyzone_t;

PyObject *tzname_obj;
if (janzone < julyzone) {
Expand Down
Loading