mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-11 03:46:17 +01:00
Merge branch 'ossfuzz-22758-date-negative-overflow' into 'master'
gdatetime: Avoid integer overflow creating dates too far in the past See merge request GNOME/glib!1671
This commit is contained in:
commit
d536afeed8
@ -1032,7 +1032,8 @@ g_date_time_new_from_unix_local (gint64 t)
|
||||
GDateTime *datetime;
|
||||
GTimeZone *local;
|
||||
|
||||
if (t > G_MAXINT64 / USEC_PER_SECOND)
|
||||
if (t > G_MAXINT64 / USEC_PER_SECOND ||
|
||||
t < G_MININT64 / USEC_PER_SECOND)
|
||||
return NULL;
|
||||
|
||||
local = g_time_zone_new_local ();
|
||||
@ -1067,7 +1068,8 @@ g_date_time_new_from_unix_utc (gint64 t)
|
||||
GDateTime *datetime;
|
||||
GTimeZone *utc;
|
||||
|
||||
if (t > G_MAXINT64 / USEC_PER_SECOND)
|
||||
if (t > G_MAXINT64 / USEC_PER_SECOND ||
|
||||
t < G_MININT64 / USEC_PER_SECOND)
|
||||
return NULL;
|
||||
|
||||
utc = g_time_zone_new_utc ();
|
||||
|
1
glib/tests/bookmarks/fail-42.xbel
Normal file
1
glib/tests/bookmarks/fail-42.xbel
Normal file
@ -0,0 +1 @@
|
||||
<xbel version="1.0"><bookmark href=""><info><metadata owner="http://freedesktop.org"><applications><application name=""exec=""timestamp="-77873021800189">
|
@ -152,7 +152,7 @@ test_GDateTime_new_from_unix (void)
|
||||
g_date_time_unref (dt);
|
||||
}
|
||||
|
||||
/* Check that trying to create a #GDateTime too far in the future reliably
|
||||
/* Check that trying to create a #GDateTime too far in the future (or past) reliably
|
||||
* fails. Previously, the checks for this overflowed and it silently returned
|
||||
* an incorrect #GDateTime. */
|
||||
static void
|
||||
@ -167,6 +167,12 @@ test_GDateTime_new_from_unix_overflow (void)
|
||||
|
||||
dt = g_date_time_new_from_unix_local (G_MAXINT64);
|
||||
g_assert_null (dt);
|
||||
|
||||
dt = g_date_time_new_from_unix_utc (G_MININT64);
|
||||
g_assert_null (dt);
|
||||
|
||||
dt = g_date_time_new_from_unix_local (G_MININT64);
|
||||
g_assert_null (dt);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user