]> jfr.im git - solanum.git/commitdiff
random_ping: stop producing negative values that become 16 chars
authorSimon Arlott <sa.me.uk>
Mon, 2 May 2016 20:14:16 +0000 (21:14 +0100)
committerSimon Arlott <sa.me.uk>
Mon, 2 May 2016 20:14:16 +0000 (21:14 +0100)
include/client.h
ircd/s_user.c
modules/m_pong.c

index 5e6da7ff6b69cbcd1a8a3092a4445ca061401af7..708bf69dc5d3923c71f777b025124ef7fa4da9a0 100644 (file)
@@ -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))):
index 39c207aeb5f1207f8e5ebc7edc887b0e043d54d8..7c668b89bf94d995559acf9ba7cbd9f81d760cd2 100644 (file)
@@ -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;
                }
index a727fcf5ccd577cb1d83e1a1c5c3ec1a00071bea..5d17215840525b85c4b928b9bb43a1f84079b79a 100644 (file)
@@ -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)