diff --git a/src/modules/m_vhost.c b/src/modules/m_vhost.c index 2f07d74b8..6fcacc092 100644 --- a/src/modules/m_vhost.c +++ b/src/modules/m_vhost.c @@ -154,16 +154,9 @@ int m_vhost(aClient *cptr, aClient *sptr, int parc, char *parv[]) /* join sent later when the host has been changed */ break; } - if (sptr->user->virthost) + safestrdup(sptr->user->virthost, vhost->virthost); + if (vhost->virtuser) { - MyFree(sptr->user->virthost); - sptr->user->virthost = NULL; - } - len = strlen(vhost->virthost); - length = len > HOSTLEN ? HOSTLEN : len; - sptr->user->virthost = MyMalloc(length + 1); - strlcpy(sptr->user->virthost, vhost->virthost, length + 1); - if (vhost->virtuser) { strcpy(olduser, sptr->user->username); strlcpy(sptr->user->username, vhost->virtuser, USERLEN); sendto_server(cptr, 0, 0, ":%s SETIDENT %s", sptr->name, diff --git a/src/s_misc.c b/src/s_misc.c index ae6b83316..4d886907e 100644 --- a/src/s_misc.c +++ b/src/s_misc.c @@ -791,10 +791,15 @@ char text[2048]; */ int valid_host(char *host) { -char *p; + char *p; + + if (strlen(host) > HOSTLEN) + return 0; /* too long hosts are invalid too */ + for (p=host; *p; p++) if (!isalnum(*p) && (*p != '_') && (*p != '-') && (*p != '.') && (*p != ':')) return 0; + return 1; }