summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorPatrick Griffis <tingping@tingping.se>2021-03-03 15:39:02 -0600
committerPatrick Griffis <tingping@tingping.se>2021-03-03 15:39:02 -0600
commit964ae72fa8c770ae45c995fbdc38cae4c7ece5a3 (patch)
tree8bc2fa3e0a580bf9a197d13c4f9798aaaac59265 /src
parent87eb72814791037d6a00fec9f71d5809f9ee600b (diff)
Better handle various ctime() calls failing
Diffstat (limited to 'src')
-rw-r--r--src/common/inbound.c6
-rw-r--r--src/common/proto-irc.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/common/inbound.c b/src/common/inbound.c
index 7ac3c71a..71c60357 100644
--- a/src/common/inbound.c
+++ b/src/common/inbound.c
@@ -815,7 +815,9 @@ inbound_topictime (server *serv, char *chan, char *nick, time_t stamp,
 	if (!sess)
 		sess = serv->server_session;
 
-	tim[24] = 0;	/* get rid of the \n */
+	if (tim != NULL)
+		tim[24] = 0;	/* get rid of the \n */
+
 	EMIT_SIGNAL_TIMESTAMP (XP_TE_TOPICDATE, sess, chan, nick, tim, NULL, 0,
 								  tags_data->timestamp);
 }
@@ -1489,7 +1491,7 @@ inbound_banlist (session *sess, time_t stamp, char *chan, char *mask,
 	server *serv = sess->server;
 	char *nl;
 
-	if (stamp <= 0)
+	if (stamp <= 0 || time_str == NULL)
 	{
 		time_str = "";
 	}
diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c
index 69501ee3..fa2d822b 100644
--- a/src/common/proto-irc.c
+++ b/src/common/proto-irc.c
@@ -454,7 +454,8 @@ channel_date (session *sess, char *chan, char *timestr,
 {
 	time_t timestamp = (time_t) atol (timestr);
 	char *tim = ctime (&timestamp);
-	tim[24] = 0;	/* get rid of the \n */
+	if (tim != NULL)
+		tim[24] = 0;	/* get rid of the \n */
 	EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANDATE, sess, chan, tim, NULL, NULL, 0,
 								  tags_data->timestamp);
 }
@@ -602,7 +603,8 @@ process_numeric (session * sess, int n,
 			else
 			{
 				tim = ctime (&timestamp);
-				tim[19] = 0; 	/* get rid of the \n */
+				if (tim != NULL)
+					tim[19] = 0; 	/* get rid of the \n */
 				EMIT_SIGNAL_TIMESTAMP (XP_TE_WHOIS4T, whois_sess, word[4],
 											  outbuf, tim, NULL, 0, tags_data->timestamp);
 			}