commit f463497462ece85332e7f28af712448ca786f2e2
parent 0be593f936eb973ab957e2a439382a58bebd864d
Author: wwp <subscript@free.fr>
Date: Mon, 3 Mar 2025 13:58:39 +0100
Fix CID 1643906: use time_t as much as possible and I/O them as long int.
Diffstat:
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/common/xml.c b/src/common/xml.c
@@ -510,6 +510,20 @@ XMLAttr *xml_attr_new_int(const gchar *name, const gint value)
return new_attr;
}
+XMLAttr *xml_attr_new_time_t(const gchar *name, const time_t value)
+{
+ XMLAttr *new_attr;
+ gchar *valuestr;
+
+ valuestr = g_strdup_printf("%ld", value);
+
+ new_attr = g_new(XMLAttr, 1);
+ new_attr->name = XML_STRING_ADD(name);
+ new_attr->value = valuestr;
+
+ return new_attr;
+}
+
void xml_tag_add_attr(XMLTag *tag, XMLAttr *attr)
{
tag->attr = g_list_prepend(tag->attr, attr);
diff --git a/src/common/xml.h b/src/common/xml.h
@@ -88,6 +88,8 @@ XMLAttr *xml_attr_new (const gchar *name,
const gchar *value);
XMLAttr *xml_attr_new_int (const gchar *name,
const gint value);
+XMLAttr *xml_attr_new_time_t (const gchar *name,
+ const time_t value);
void xml_tag_add_attr (XMLTag *tag,
XMLAttr* attr);
diff --git a/src/imap.c b/src/imap.c
@@ -6318,9 +6318,9 @@ static void imap_item_set_xml(Folder *folder, FolderItem *item, XMLTag *tag)
if (!strcmp(attr->name, "uidnext"))
IMAP_FOLDER_ITEM(item)->uid_next = atoi(attr->value);
if (!strcmp(attr->name, "last_sync"))
- IMAP_FOLDER_ITEM(item)->last_sync = atoi(attr->value);
+ IMAP_FOLDER_ITEM(item)->last_sync = (time_t)atol(attr->value);
if (!strcmp(attr->name, "last_change"))
- IMAP_FOLDER_ITEM(item)->last_change = atoi(attr->value);
+ IMAP_FOLDER_ITEM(item)->last_change = (time_t)atol(attr->value);
}
if (IMAP_FOLDER_ITEM(item)->last_change == 0)
IMAP_FOLDER_ITEM(item)->last_change = time(NULL);
@@ -6336,9 +6336,9 @@ static XMLTag *imap_item_get_xml(Folder *folder, FolderItem *item)
#ifdef HAVE_LIBETPAN
xml_tag_add_attr(tag, xml_attr_new_int("uidnext",
IMAP_FOLDER_ITEM(item)->uid_next));
- xml_tag_add_attr(tag, xml_attr_new_int("last_sync",
+ xml_tag_add_attr(tag, xml_attr_new_time_t("last_sync",
IMAP_FOLDER_ITEM(item)->last_sync));
- xml_tag_add_attr(tag, xml_attr_new_int("last_change",
+ xml_tag_add_attr(tag, xml_attr_new_time_t("last_change",
IMAP_FOLDER_ITEM(item)->last_change));
#endif