From 472b2e169179d112dfe52a18475aa856b030d877 Mon Sep 17 00:00:00 2001 From: Kobi Shmueli Date: Thu, 23 Oct 2008 01:27:20 +0200 Subject: [PATCH] Fixes for x64: - Hosts weren't resolved - NICK sent bogus servicestamps and IPs --- include/struct.h | 2 +- src/ircsprintf.c | 22 +++++++++++++++++++--- src/m_server.c | 2 +- src/res.c | 17 +++++++++++------ src/s_user.c | 2 +- 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/include/struct.h b/include/struct.h index 4c3acfb..03df7f9 100644 --- a/include/struct.h +++ b/include/struct.h @@ -779,7 +779,7 @@ struct User char host[HOSTLEN + 1]; char *server; /* pointer to scached server name */ unsigned int servicetype; /* set by SVSMODE +T */ - unsigned int servicestamp; /* set by SVSMODE +d */ + unsigned long servicestamp; /* set by SVSMODE +d */ AliasInfo *alias; /* shortform alias data for U:lined clients */ /* * In a perfect world the 'server' name should not be needed, a diff --git a/src/ircsprintf.c b/src/ircsprintf.c index 4841047..45031a7 100644 --- a/src/ircsprintf.c +++ b/src/ircsprintf.c @@ -1,6 +1,6 @@ #include "ircsprintf.h" -char num[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +char num[24] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; char itoa_tab[10] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; char xtoa_tab[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; @@ -54,10 +54,26 @@ inline int irc_printf(char *str, const char *pattern, va_list vl) } else u=0; - /* fallthrough */ + i=va_arg(ap, unsigned long); + if(!u) + if(i&0x80000000) + { + buf[len++]='-'; /* it's negative.. */ + i = 0x80000000 - (i & ~0x80000000); + } + s=&num[23]; + do + { + *--s=itoa_tab[i%10]; + i/=10; + } while(i!=0); + while(*s) + buf[len++]=*s++; + format++; + break; case 'd': case 'i': - i=va_arg(ap, unsigned long); + i=va_arg(ap, unsigned int); if(!u) if(i&0x80000000) { diff --git a/src/m_server.c b/src/m_server.c index 43c5699..ba696e3 100644 --- a/src/m_server.c +++ b/src/m_server.c @@ -48,7 +48,7 @@ static void sendnick_TS(aClient *cptr, aClient *acptr) ubuf[0] = '+'; ubuf[1] = '\0'; } - sendto_one(cptr, "NICK %s %d %ld %s %s %s %s %lu %lu :%s", + sendto_one(cptr, "NICK %s %d %ld %s %s %s %s %lu %u :%s", acptr->name, acptr->hopcount + 1, acptr->tsinfo, ubuf, acptr->user->username, acptr->user->host, acptr->user->server, acptr->user->servicestamp, diff --git a/src/res.c b/src/res.c index a0168d8..852a86e 100644 --- a/src/res.c +++ b/src/res.c @@ -51,6 +51,11 @@ #undef DEBUG /* because theres alot of debug code in here */ +#define TYPE_SIZE 2 +#define CLASS_SIZE 2 +#define TTL_SIZE 4 +#define DLEN_SIZE 2 + extern int dn_expand(char *, char *, char *, char *, int); extern int dn_skipname(char *, char *); extern int @@ -736,9 +741,9 @@ static int proc_answer(ResRQ * rptr, HEADER *hptr, char *buf, char *eob) hostbuf[HOSTLEN] = '\0'; cp += n; type = (int) _getshort(cp); - cp += sizeof(short); + cp += TYPE_SIZE; class = (int) _getshort(cp); - cp += sizeof(short); + cp += CLASS_SIZE; if(class != C_IN) { sendto_realops_lev(DEBUG_LEV, @@ -799,15 +804,15 @@ static int proc_answer(ResRQ * rptr, HEADER *hptr, char *buf, char *eob) break; cp += n; type = (int) _getshort(cp); - cp += sizeof(short); + cp += TYPE_SIZE; class = (int) _getshort(cp); - cp += sizeof(short); + cp += CLASS_SIZE; rptr->ttl = _getlong(cp); - cp += sizeof(rptr->ttl); + cp += TTL_SIZE; dlen = (int) _getshort(cp); - cp += sizeof(short); + cp += DLEN_SIZE; /* Wait to set rptr->type until we verify this structure */ diff --git a/src/s_user.c b/src/s_user.c index ba8867e..8b938b1 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -1055,7 +1055,7 @@ register_user(aClient *cptr, aClient *sptr, char *nick, char *username) ubuf[1] = '\0'; } hash_check_watch(sptr, RPL_LOGON); - sendto_serv_butone(cptr, "NICK %s %d %ld %s %s %s %s %lu %lu :%s", + sendto_serv_butone(cptr, "NICK %s %d %ld %s %s %s %s %lu %u :%s", nick, sptr->hopcount + 1, sptr->tsinfo, ubuf, user->username, user->host, user->server, sptr->user->servicestamp, -- 1.5.3.8