random_ping: stop producing negative values that become 16 chars

This commit is contained in:
Simon Arlott 2016-05-02 21:14:16 +01:00
parent 84d0b55e76
commit da20854e83
No known key found for this signature in database
GPG key ID: C8975F2043CA5D24
3 changed files with 5 additions and 5 deletions

View 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))):

View 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;
}

View 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)