[PATCH 1/2] Fix relaying of NICKIPSTR NICK messages.

--- include/send.h | 1 + src/s_user.c | 29 ++++++++++++----------------- src/send.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/include/send.h b/include/send.h index 0bc3a89..a96adda 100644 --- a/include/send.h +++ b/include/send.h @@ -74,6 +74,7 @@ extern void sendto_realops_lev(int lev, char *pattern, ...) ATTRIBUTE_PRINTF(2, extern void sendto_realops(char *pattern, ...) ATTRIBUTE_PRINTF(1, 2); extern void sendto_non_noquit_servs_butone(aClient *one, char *pattern, ...) ATTRIBUTE_PRINTF(2, 3); extern void sendto_serv_butone(aClient *one, char *pattern, ...) ATTRIBUTE_PRINTF(2, 3); +extern void sendto_serv_butone_nickipstr(aClient *one, int flag, char *pattern, ...) ATTRIBUTE_PRINTF(3, 4); extern void sendto_serv_butone_super(aClient *one, int flag, char *pattern, ...) ATTRIBUTE_PRINTF(3, 4); extern void sendto_wallops_butone(aClient *one, aClient *from, char *pattern, ...) ATTRIBUTE_PRINTF(3, 4); diff --git a/src/s_user.c b/src/s_user.c index 17da791..6e582bb 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -1078,23 +1078,18 @@ register_user(aClient *cptr, aClient *sptr, char *nick, char *username, ubuf[1] = '\0'; } hash_check_watch(sptr, RPL_LOGON); - if (IsNickIPStr(cptr)) - { - sendto_serv_butone(cptr, "NICK %s %d %ld %s %s %s %s %lu %s :%s", - nick, sptr->hopcount + 1, sptr->tsinfo, ubuf, - user->username, user->host, user->server, - sptr->user->servicestamp, - cipntoa(sptr), sptr->info); - } - else - { - 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, - (sptr->ip_family == AF_INET) ? - htonl(sptr->ip.ip4.s_addr) : 1, sptr->info); - } + + sendto_serv_butone_nickipstr(cptr, 1, "NICK %s %d %ld %s %s %s %s %lu %s :%s", + nick, sptr->hopcount + 1, sptr->tsinfo, ubuf, + user->username, user->host, user->server, + sptr->user->servicestamp, + cipntoa(sptr), sptr->info); + sendto_serv_butone_nickipstr(cptr, 0, "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, + (sptr->ip_family == AF_INET) ? + htonl(sptr->ip.ip4.s_addr) : 1, sptr->info); if(MyClient(sptr)) { diff --git a/src/send.c b/src/send.c index d81d504..de4f1ea 100644 --- a/src/send.c +++ b/src/send.c @@ -760,6 +760,39 @@ void sendto_non_noquit_servs_butone(aClient *one, char *pattern, ...) #endif /* + * sendto_server_butone_nickipstr + * + * Send a message to all connected servers except the client 'one'. Also select + * servers that do or do not have the NICKIPSTR capability. + */ +void sendto_serv_butone_nickipstr(aClient *one, int flag, char *pattern, ...) +{ + aClient *cptr; + int k = 0; + fdlist send_fdlist; + va_list vl; + DLink *lp; + + va_start(vl, pattern); + for(lp = server_list; lp; lp = lp->next) + { + cptr = lp->value.cptr; + if (one && cptr == one->from) + continue; + if (flag && !IsNickIPStr(cptr)) + continue; + if (!flag && IsNickIPStr(cptr)) + continue; + send_fdlist.entry[++k] = cptr->fd; + } + send_fdlist.last_entry = k; + if (k) + vsendto_fdlist(&send_fdlist, pattern, vl); + va_end(vl); + return; +} + +/* * sendto_server_butone * * Send a message to all connected servers except the client 'one'. -- 1.7.2.3

Some htonl calls were missing when checking for the 0.0.0.1 IP address, which indicates that a non-IPv4 address was passed through a server that does not have the NICKIPSTR capability. Also ensure that the hostip field is correctly set for numeric IP addresses. --- src/s_user.c | 9 +++++++-- src/struct.c | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/s_user.c b/src/s_user.c index 6e582bb..dd55f9b 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -2167,10 +2167,15 @@ do_user(char *nick, aClient *cptr, aClient *sptr, char *username, char *host, unsigned long l; l = ntohl(strtoul(ip, &end, 10)); - if (*ip != '\0' && *end == '\0' && l != 1) + if (*ip != '\0' && *end == '\0') { - sptr->ip_family = AF_INET; + if (l != htonl(1)) + sptr->ip_family = AF_INET; + else + sptr->ip_family = 0; + sptr->ip.ip4.s_addr = l; + ip = inetntoa((char *)&sptr->ip); } else sptr->ip_family = 0; diff --git a/src/struct.c b/src/struct.c index a3d705e..55107d7 100644 --- a/src/struct.c +++ b/src/struct.c @@ -128,7 +128,11 @@ struct in_addr ac_ip(aClient *cptr) if (cptr->ip_family == AF_INET) return cptr->ip.ip4; else - return (struct in_addr){1}; + { + int ip = htonl(1); + + return (struct in_addr){ip}; + } } char *ac_hostip(aClient *cptr) -- 1.7.2.3
participants (1)
-
Ned T. Crigler