Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
m_webirc: use rb_inet_ntop_sock to populate sockhost
Browse files Browse the repository at this point in the history
  • Loading branch information
nomis committed Jun 27, 2017
1 parent d58d978 commit eb5b343
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions extensions/m_webirc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,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;
Expand Down Expand Up @@ -128,23 +127,15 @@ 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
rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));

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))))
Expand Down

0 comments on commit eb5b343

Please sign in to comment.