Navigation Menu

Skip to content

Commit

Permalink
Totally remove []s from IPv6 address if present
Browse files Browse the repository at this point in the history
Found by: Geo
Patch by: Geo

This removes []s from an address before Eggdrop does anything with it at all, particularly writing it to the userfile. This also sanitizes the value so that things like .tcl getuser testbot botaddr will return the actual IP without []s around it, since this value was previously written to the userfile with the []s included.

* Remove []s from IPv6 address if present
* Update chaddr code as well
  • Loading branch information
vanosg committed Nov 24, 2017
1 parent 48983f3 commit f0f2f08
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/cmds.c
Expand Up @@ -869,6 +869,11 @@ static void cmd_pls_bot(struct userrec *u, int idx, char *par)
if (strlen(addr) > 60)
addr[60] = 0;

/* Trim IPv6 []s out if present */
if (addr[0] == '[') {
addr[strlen(addr)-1] = 0;
memmove(addr, addr + 1, strlen(addr));
}
userlist = adduser(userlist, handle, "none", "-", USER_BOT);
u1 = get_user_by_handle(userlist, handle);
bi = user_malloc(sizeof(struct bot_addr));
Expand Down Expand Up @@ -904,11 +909,6 @@ static void cmd_pls_bot(struct userrec *u, int idx, char *par)
putlog(LOG_CMDS, "*", "#%s# +bot %s %s%s%s%s%s %s%s", dcc[idx].nick, handle,
addr, port ? " " : "", port ? port : "", relay ? " " : "",
relay ? relay : "", host[0] ? " " : "", host);
/* Trim IPv6 []s out for display purposes */
if (addr[0] == '[') {
addr[strlen(addr)-1] = 0;
memmove(addr, addr + 1, strlen(addr));
}
#ifdef TLS
dprintf(idx, "Added bot '%s' with address [%s]:%s%d/%s%d and %s%s%s.\n",
handle, addr, (bi->ssl & TLS_BOT) ? "+" : "", bi->telnet_port,
Expand Down Expand Up @@ -1220,6 +1220,11 @@ static void cmd_chaddr(struct userrec *u, int idx, char *par)
#endif
}

/* Trim IPv6 []s out if present */
if (addr[0] == '[') {
addr[strlen(addr)-1] = 0;
memmove(addr, addr + 1, strlen(addr));
}
bi = user_malloc(sizeof(struct bot_addr));
bi->address = user_malloc(strlen(addr) + 1);
strcpy(bi->address, addr);
Expand Down

0 comments on commit f0f2f08

Please sign in to comment.