From da20854e834f8f52cbf38372724c74b41d0bcbfd Mon Sep 17 00:00:00 2001
From: Simon Arlott <sa.me.uk>
Date: Mon, 2 May 2016 21:14:16 +0100
Subject: [PATCH] random_ping: stop producing negative values that become 16
 chars

---
 include/client.h | 2 +-
 ircd/s_user.c    | 6 +++---
 modules/m_pong.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/client.h b/include/client.h
index 5e6da7ff6..708bf69dc 100644
--- a/include/client.h
+++ b/include/client.h
@@ -254,7 +254,7 @@ struct LocalUser
 	 */
 	int sent_parsed;	/* how many messages we've parsed in this second */
 	time_t last_knock;	/* time of last knock */
-	unsigned long random_ping;
+	uint32_t random_ping;
 
 	/* target change stuff */
 	/* targets we're aware of (fnv32(use_id(target_p))):
diff --git a/ircd/s_user.c b/ircd/s_user.c
index 39c207aeb..7c668b89b 100644
--- a/ircd/s_user.c
+++ b/ircd/s_user.c
@@ -367,9 +367,9 @@ register_local_user(struct Client *client_p, struct Client *source_p)
 	{
 		if(!(source_p->flags & FLAGS_PINGSENT) && source_p->localClient->random_ping == 0)
 		{
-			source_p->localClient->random_ping = (unsigned long) (rand() * rand()) << 1;
-			sendto_one(source_p, "PING :%08lX",
-				   (unsigned long) source_p->localClient->random_ping);
+			source_p->localClient->random_ping = (uint32_t)(((rand() * rand()) << 1) | 1);
+			sendto_one(source_p, "PING :%08X",
+				   (unsigned int) source_p->localClient->random_ping);
 			source_p->flags |= FLAGS_PINGSENT;
 			return -1;
 		}
diff --git a/modules/m_pong.c b/modules/m_pong.c
index a727fcf5c..5d1721584 100644
--- a/modules/m_pong.c
+++ b/modules/m_pong.c
@@ -104,7 +104,7 @@ mr_pong(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
 	{
 		if(ConfigFileEntry.ping_cookie && source_p->flags & FLAGS_SENTUSER && source_p->name[0])
 		{
-			unsigned long incoming_ping = strtoul(parv[1], NULL, 16);
+			uint32_t incoming_ping = strtoul(parv[1], NULL, 16);
 			if(incoming_ping)
 			{
 				if(source_p->localClient->random_ping == incoming_ping)