summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2020-11-20 13:37:50 +0300
committerdefanor <defanor@uberspace.net>2020-11-20 13:37:50 +0300
commitc8ac9bbf2e9d0bb800b0353dde96fb22a7d2abdb (patch)
tree723da4373b8460216ada582c0c30c7f548f2c1c9
parent9f1d72a7526cd9e8c011724bec5901b63c30e5b1 (diff)
Use gmtime_r instead of gmtime
-rw-r--r--src/rexmpp.c6
-rw-r--r--src/rexmpp_openpgp.c16
2 files changed, 14 insertions, 8 deletions
diff --git a/src/rexmpp.c b/src/rexmpp.c
index c75f9b2..e9adeef 100644
--- a/src/rexmpp.c
+++ b/src/rexmpp.c
@@ -8,6 +8,7 @@
#include <string.h>
#include <sys/time.h>
+#include <time.h>
#include <errno.h>
#include <syslog.h>
#include <arpa/nameser.h>
@@ -684,8 +685,9 @@ xmlNodePtr rexmpp_xml_set_delay (rexmpp_t *s, xmlNodePtr node) {
}
char buf[42];
time_t t = time(NULL);
- struct tm *utc_time = gmtime(&t);
- strftime(buf, 42, "%FT%TZ", utc_time);
+ struct tm utc_time;
+ gmtime_r(&t, &utc_time);
+ strftime(buf, 42, "%FT%TZ", &utc_time);
xmlNodePtr delay = xmlNewChild(node, NULL, "delay", NULL);
xmlNewProp(delay, "stamp", buf);
if (s != NULL && s->assigned_jid.full[0]) {
diff --git a/src/rexmpp_openpgp.c b/src/rexmpp_openpgp.c
index c7f0eff..5d4d5af 100644
--- a/src/rexmpp_openpgp.c
+++ b/src/rexmpp_openpgp.c
@@ -8,6 +8,7 @@
#include <syslog.h>
#include <string.h>
+#include <time.h>
#include <gpgme.h>
#include <libxml/tree.h>
@@ -210,8 +211,9 @@ void rexmpp_pgp_key_publish_iq (rexmpp_t *s,
char time_str[42];
time_t t = time(NULL);
- struct tm *utc_time = gmtime(&t);
- strftime(time_str, 42, "%FT%TZ", utc_time);
+ struct tm utc_time;
+ gmtime_r(&t, &utc_time);
+ strftime(time_str, 42, "%FT%TZ", &utc_time);
xmlNodePtr metadata = xmlNewNode(NULL, "pubkey-metadata");
xmlNewNs(metadata, "urn:xmpp:openpgp:0", NULL);
@@ -292,8 +294,9 @@ rexmpp_err_t rexmpp_openpgp_publish_key (rexmpp_t *s, const char *fp) {
char time_str[42];
time_t t = time(NULL);
- struct tm *utc_time = gmtime(&t);
- strftime(time_str, 42, "%FT%TZ", utc_time);
+ struct tm utc_time;
+ gmtime_r(&t, &utc_time);
+ strftime(time_str, 42, "%FT%TZ", &utc_time);
xmlNodePtr item = xmlNewNode(NULL, "item");
xmlNewNs(item, "http://jabber.org/protocol/pubsub", NULL);
@@ -442,8 +445,9 @@ char *rexmpp_openpgp_encrypt_sign (rexmpp_t *s,
/* Add timestamp. */
char time_str[42];
time_t t = time(NULL);
- struct tm *utc_time = gmtime(&t);
- strftime(time_str, 42, "%FT%TZ", utc_time);
+ struct tm utc_time;
+ gmtime_r(&t, &utc_time);
+ strftime(time_str, 42, "%FT%TZ", &utc_time);
xmlNodePtr time = xmlNewNode(NULL, "time");
xmlNewNs(time, "urn:xmpp:openpgp:0", NULL);