Merge pull request #647 from bebehei/issue-646-overflow-tests

Don't overflow when passing INT_MAX on DBus wire
This commit is contained in:
Nikos Tsipinakis 2019-08-09 16:29:12 +03:00 committed by GitHub
commit 13307d2b17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -286,7 +286,7 @@ static struct notification *dbus_message_to_notification(const gchar *sender, GV
}
if (timeout >= 0)
n->timeout = timeout * 1000;
n->timeout = ((gint64)timeout) * 1000;
g_variant_unref(hints);
g_variant_type_free(required_type);

View File

@ -660,6 +660,34 @@ TEST test_hint_raw_image(void)
PASS();
}
/* We didn't process the timeout parameter via DBus correctly
* and it got limited to an int instead of a long int
* See: Issue #646 (The timeout value in dunst wraps around) */
TEST test_timeout_overflow(void)
{
struct notification *n;
struct dbus_notification *n_dbus;
n_dbus = dbus_notification_new();
n_dbus->app_name = "dunstteststack";
n_dbus->app_icon = "NONE";
n_dbus->summary = "test_hint_urgency";
n_dbus->body = "Summary of it";
n_dbus->expire_timeout = 2147484;
gint64 expected_timeout = G_GINT64_CONSTANT(2147484000);
guint id;
ASSERT(dbus_notification_fire(n_dbus, &id));
ASSERT(id != 0);
n = queues_debug_find_notification_by_id(id);
ASSERT_EQ_FMT(expected_timeout, n->timeout, "%" G_GINT64_FORMAT);
dbus_notification_free(n_dbus);
PASS();
}
TEST test_server_caps(enum markup_mode markup)
{
GVariant *reply;
@ -821,6 +849,7 @@ gpointer run_threaded_tests(gpointer data)
RUN_TESTp(test_server_caps, MARKUP_NO);
RUN_TEST(test_close_and_signal);
RUN_TEST(test_signal_actioninvoked);
RUN_TEST(test_timeout_overflow);
RUN_TEST(assert_methodlists_sorted);