From a5404172c843dae2b7905934c671548f409e16e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 21 Jun 2026 07:45:22 +0200 Subject: [PATCH] perl: fix conversion of dates in the API functions On modern 32-bit platforms with a 64-bit time_t, the value returned by SvIV can be 32-bit (its width depends on how Perl was built), whereas time_t is 64-bit. Read the date with SvNV instead: a double represents all real timestamps exactly, so the conversion to time_t no longer depends on the size of the Perl integer type. --- CHANGELOG.md | 2 +- src/plugins/perl/weechat-perl-api.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bc0cfbb2..59a50edf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - api: fix infinite loop in function string_replace when the search string is empty - irc: fix tag in message with list of names when joining a channel - fset: remove error displayed in core buffer when clicking with the mouse below the last option displayed -- guile, lua: fix conversion of dates in the API functions +- guile, lua, perl: fix conversion of dates in the API functions - irc: limit size of data received from the server to prevent memory exhaustion - irc: fix out-of-bounds read on incoming DCC command with a quoted filename ending the message ([#2322](https://github.com/weechat/weechat/issues/2322)) - relay: limit size of decompressed websocket frame with permessage-deflate to prevent memory exhaustion ([GHSA-v2v4-45wm-5cr3](https://github.com/weechat/weechat/security/advisories/GHSA-v2v4-45wm-5cr3), [CVE-2026-53524](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2026-53524)) diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index 7c3b400df..550b57671 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -2106,7 +2106,7 @@ API_FUNC(print_date_tags) plugin_script_api_printf_date_tags (weechat_perl_plugin, perl_current_script, API_STR2PTR(buffer), - (time_t)(SvIV (ST (1))), /* date */ + (time_t)(SvNV (ST (1))), /* date */ tags, "%s", message); @@ -2129,7 +2129,7 @@ API_FUNC(print_datetime_tags) plugin_script_api_printf_datetime_tags (weechat_perl_plugin, perl_current_script, API_STR2PTR(buffer), - (time_t)(SvIV (ST (1))), /* date */ + (time_t)(SvNV (ST (1))), /* date */ SvIV (ST (2)), /* date_usec */ tags, "%s", message); @@ -2175,7 +2175,7 @@ API_FUNC(print_y_date_tags) perl_current_script, API_STR2PTR(buffer), SvIV (ST (1)), /* y */ - (time_t)(SvIV (ST (2))), /* date */ + (time_t)(SvNV (ST (2))), /* date */ tags, "%s", message); @@ -2199,7 +2199,7 @@ API_FUNC(print_y_datetime_tags) perl_current_script, API_STR2PTR(buffer), SvIV (ST (1)), /* y */ - (time_t)(SvIV (ST (2))), /* date */ + (time_t)(SvNV (ST (2))), /* date */ SvIV (ST (3)), /* date_usec */ tags, "%s", message); @@ -4940,7 +4940,7 @@ API_FUNC(infolist_new_var_time) result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(item), name, - (time_t)(SvIV (ST (2))))); /* value */ + (time_t)(SvNV (ST (2))))); /* value */ API_RETURN_STRING(result); }