From fdfe62e7cc0def16f09feef3d7cd9ef4cd93e24b Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Tue, 27 Jun 2017 20:45:02 +0100 Subject: [PATCH] m_webirc: use rb_inet_ntop_sock to populate sockhost --- extensions/m_webirc.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/extensions/m_webirc.c b/extensions/m_webirc.c index 99f66b5b..6b86ee4a 100644 --- a/extensions/m_webirc.c +++ b/extensions/m_webirc.c @@ -81,8 +81,7 @@ mr_webirc(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc struct rb_sockaddr_storage addr; if ((!strchr(parv[4], '.') && !strchr(parv[4], ':')) || - strlen(parv[4]) + (*parv[4] == ':') >= - sizeof(source_p->sockhost)) + strlen(parv[4]) >= sizeof(source_p->sockhost)) { sendto_one(source_p, "NOTICE * :Invalid IP"); return; @@ -126,16 +125,6 @@ mr_webirc(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc return; } - if (*parv[4] == ':') - { - source_p->sockhost[0] = '0'; - rb_strlcpy(source_p->sockhost + 1, parv[4], - sizeof(source_p->sockhost) - 1); - } - else - rb_strlcpy(source_p->sockhost, parv[4], - sizeof(source_p->sockhost)); - if(strlen(parv[3]) <= HOSTLEN) rb_strlcpy(source_p->host, parv[3], sizeof(source_p->host)); else @@ -143,6 +132,8 @@ mr_webirc(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc source_p->localClient->ip = addr; + rb_inet_ntop_sock((struct sockaddr *)&source_p->localClient->ip, source_p->sockhost, sizeof(source_p->sockhost)); + /* Check dlines now, klines will be checked on registration */ if((aconf = find_dline((struct sockaddr *)&source_p->localClient->ip, GET_SS_FAMILY(&source_p->localClient->ip))))