From 914d3df6391701675d5801950a9e7e11cb91c07d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 21 Jun 2026 07:46:15 +0200 Subject: [PATCH] python: fix conversion of dates in the API functions On modern 32-bit platforms with a 64-bit time_t, long is 32-bit but time_t is 64-bit. Use "long long" for variables cast to time_t. --- CHANGELOG.md | 2 +- src/plugins/python/weechat-python-api.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59a50edf5..04296c3fa 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, perl: fix conversion of dates in the API functions +- guile, lua, perl, python: 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/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index b28abfbc0..498ece6d7 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -2093,14 +2093,14 @@ API_FUNC(prnt) API_FUNC(prnt_date_tags) { char *buffer, *tags, *message; - long date; + long long date; API_INIT_FUNC(1, "prnt_date_tags", API_RETURN_ERROR); buffer = NULL; date = 0; tags = NULL; message = NULL; - if (!PyArg_ParseTuple (args, "slss", &buffer, &date, &tags, &message)) + if (!PyArg_ParseTuple (args, "sLss", &buffer, &date, &tags, &message)) API_WRONG_ARGS(API_RETURN_ERROR); plugin_script_api_printf_date_tags (weechat_python_plugin, @@ -2116,7 +2116,7 @@ API_FUNC(prnt_date_tags) API_FUNC(prnt_datetime_tags) { char *buffer, *tags, *message; - long date; + long long date; int date_usec; API_INIT_FUNC(1, "prnt_datetime_tags", API_RETURN_ERROR); @@ -2125,7 +2125,7 @@ API_FUNC(prnt_datetime_tags) date_usec = 0; tags = NULL; message = NULL; - if (!PyArg_ParseTuple (args, "sliss", &buffer, &date, &date_usec, &tags, + if (!PyArg_ParseTuple (args, "sLiss", &buffer, &date, &date_usec, &tags, &message)) API_WRONG_ARGS(API_RETURN_ERROR); @@ -2165,7 +2165,7 @@ API_FUNC(prnt_y_date_tags) { char *buffer, *tags, *message; int y; - long date; + long long date; API_INIT_FUNC(1, "prnt_y_date_tags", API_RETURN_ERROR); buffer = NULL; @@ -2173,7 +2173,7 @@ API_FUNC(prnt_y_date_tags) date = 0; tags = NULL; message = NULL; - if (!PyArg_ParseTuple (args, "silss", &buffer, &y, &date, &tags, &message)) + if (!PyArg_ParseTuple (args, "siLss", &buffer, &y, &date, &tags, &message)) API_WRONG_ARGS(API_RETURN_ERROR); plugin_script_api_printf_y_date_tags (weechat_python_plugin, @@ -2191,7 +2191,7 @@ API_FUNC(prnt_y_datetime_tags) { char *buffer, *tags, *message; int y; - long date; + long long date; int date_usec; API_INIT_FUNC(1, "prnt_y_datetime_tags", API_RETURN_ERROR); @@ -2201,7 +2201,7 @@ API_FUNC(prnt_y_datetime_tags) date_usec = 0; tags = NULL; message = NULL; - if (!PyArg_ParseTuple (args, "siliss", &buffer, &y, &date, &date_usec, + if (!PyArg_ParseTuple (args, "siLiss", &buffer, &y, &date, &date_usec, &tags, &message)) API_WRONG_ARGS(API_RETURN_ERROR); @@ -4904,13 +4904,13 @@ API_FUNC(infolist_new_var_time) { char *item, *name; const char *result; - long value; + long long value; API_INIT_FUNC(1, "infolist_new_var_time", API_RETURN_EMPTY); item = NULL; name = NULL; value = 0; - if (!PyArg_ParseTuple (args, "ssl", &item, &name, &value)) + if (!PyArg_ParseTuple (args, "ssL", &item, &name, &value)) API_WRONG_ARGS(API_RETURN_EMPTY); result = API_PTR2STR(weechat_infolist_new_var_time (API_STR2PTR(item),