summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorAlexander Kanavin <alex@linutronix.de>2023-08-22 14:02:16 +0200
committerAlexander Kanavin <alex@linutronix.de>2023-08-23 14:42:05 +0200
commit4c658af0b8524caaaa25a94f82c918e1bd7e8545 (patch)
treea317e32f7e1b605e51ac92a0d412c3f75ac5c19d /bus
parent67a7ee7792d30f8f64ca2d517b1a9339c67ebed5 (diff)
time: use dbus_int64_t for seconds instead of long
On 32 bit systems long will overflow in 2038, causing complete breakage. This is confirmed by running dbus's test suite on a 32 bit system with system time set to 2040 (and configured to use 64 bit time_t of course). Note that both timespec and timeval are specified with time_t for the seconds component. This should propagate everywhere where that data is passed and stored, but previously _dbus_get_monotonic_time() and _dbus_get_monotonic_time() would truncate it to long. Also add a function for parsing dbus_int64_t from files, as existing functions can only handle long. Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Diffstat (limited to 'bus')
-rw-r--r--bus/connection.c5
-rw-r--r--bus/expirelist.c19
-rw-r--r--bus/expirelist.h2
3 files changed, 16 insertions, 10 deletions
diff --git a/bus/connection.c b/bus/connection.c
index 3643f0c6..f0177c6f 100644
--- a/bus/connection.c
+++ b/bus/connection.c
@@ -107,7 +107,7 @@ typedef struct
BusSELinuxID *selinux_id;
BusAppArmorConfinement *apparmor_confinement;
- long connection_tv_sec; /**< Time when we connected (seconds component) */
+ dbus_int64_t connection_tv_sec; /**< Time when we connected (seconds component) */
long connection_tv_usec; /**< Time when we connected (microsec component) */
int stamp; /**< connections->stamp last time we were traversed */
BusExtraHeaders want_headers;
@@ -967,7 +967,8 @@ bus_connections_expire_incomplete (BusConnections *connections)
if (connections->incomplete != NULL)
{
- long tv_sec, tv_usec;
+ dbus_int64_t tv_sec;
+ long tv_usec;
DBusList *link;
int auth_timeout;
diff --git a/bus/expirelist.c b/bus/expirelist.c
index 684387ca..cfb85c00 100644
--- a/bus/expirelist.c
+++ b/bus/expirelist.c
@@ -125,7 +125,7 @@ bus_expire_list_recheck_immediately (BusExpireList *list)
static int
do_expiration_with_monotonic_time (BusExpireList *list,
- long tv_sec,
+ dbus_int64_t tv_sec,
long tv_usec)
{
DBusList *link;
@@ -193,7 +193,8 @@ bus_expirelist_expire (BusExpireList *list)
if (list->items != NULL)
{
- long tv_sec, tv_usec;
+ dbus_int64_t tv_sec;
+ long tv_usec;
_dbus_get_monotonic_time (&tv_sec, &tv_usec);
@@ -305,7 +306,7 @@ test_expire_func (BusExpireList *list,
}
static void
-time_add_milliseconds (long *tv_sec,
+time_add_milliseconds (dbus_int64_t *tv_sec,
long *tv_usec,
int milliseconds)
{
@@ -323,10 +324,14 @@ bus_expire_list_test (const char *test_data_dir _DBUS_GNUC_UNUSED)
{
DBusLoop *loop;
BusExpireList *list;
- long tv_sec, tv_usec;
- long tv_sec_not_expired, tv_usec_not_expired;
- long tv_sec_expired, tv_usec_expired;
- long tv_sec_past, tv_usec_past;
+ dbus_int64_t tv_sec;
+ long tv_usec;
+ dbus_int64_t tv_sec_not_expired;
+ long tv_usec_not_expired;
+ dbus_int64_t tv_sec_expired;
+ long tv_usec_expired;
+ dbus_int64_t tv_sec_past;
+ long tv_usec_past;
TestExpireItem *item;
int next_interval;
dbus_bool_t result = FALSE;
diff --git a/bus/expirelist.h b/bus/expirelist.h
index 456cff71..b16f138e 100644
--- a/bus/expirelist.h
+++ b/bus/expirelist.h
@@ -41,7 +41,7 @@ typedef dbus_bool_t (* BusExpireFunc) (BusExpireList *list,
/* embed this in a child expire item struct */
struct BusExpireItem
{
- long added_tv_sec; /**< Time we were added (seconds component) */
+ dbus_int64_t added_tv_sec; /**< Time we were added (seconds component) */
long added_tv_usec; /**< Time we were added (microsec component) */
};