talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 1a795ba0b6f680faa7b4c58e6f39b1f62d61a13d
parent 9d22fe3a0d1b643a265c9cb4ef9498cc15a0c38a
Author: Jonathan Boeing <jonathan@claws-mail.org>
Date:   Sat,  4 Nov 2023 20:59:18 -0700

Fix -Wstringop-truncation warnings

Diffstat:
Msrc/plugins/vcalendar/vcal_manager.c | 19++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/plugins/vcalendar/vcal_manager.c b/src/plugins/vcalendar/vcal_manager.c @@ -536,10 +536,23 @@ static void get_rfc822_date_from_time_t(gchar *buf, gint len, time_t t) day, dd, mon, yyyy, hh, mm, ss, tzoffset(&t)); #else GDateTime *dt = g_date_time_new_from_unix_local(t); - gchar *buf2 = g_date_time_format(dt, "%a, %e %b %Y %H:%M:%S %z"); + if (dt == NULL) { + g_warning("failed getting date/time"); + g_snprintf(buf, len, "(NULL)"); + return; + } + + gchar *ret = g_date_time_format(dt, "%a, %e %b %Y %T %z"); g_date_time_unref(dt); - strncpy(buf, buf2, len); - g_free(buf2); + + if (ret == NULL) { + g_warning("failed formatting date/time"); + g_snprintf(buf, len, "(NULL)"); + return; + } + + g_snprintf(buf, len, ret); + g_free(ret); #endif }