Fix numeric IPv6 address handling

This patch fix a issue with numeric IPv6 addresses in the
tftpd -a address[:port] option.

Since IPv6 addresses use colon ':' in differnt counts itself, we cannot detect,
if the last colon is a seperator, so it is needed to put the IPv6 address into
square brackets, e.g. [2001:db8::1], so a optional port assignment is
unambiguous.
The patch also allows to specify numeric IPv6 addresses in other places enclosed
in [], but in these cases it accept these also without [].

Signed-off-by: Karsten Keil <kkeil@suse.de>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
Karsten Keil 2008-07-30 16:15:10 +02:00 committed by H. Peter Anvin
parent c3a5c712e2
commit cfb85d4dec
4 changed files with 102 additions and 6 deletions

View file

@ -73,6 +73,18 @@ union sock_addr {
(void *)&((union sock_addr*)sock)->si.sin_addr
#endif
#ifdef HAVE_IPV6
int is_numeric_ipv6(char *);
char *strip_address(char *);
#else
#define is_numeric_ipv6(a) 0
static inline char *strip_address(char *addr)
{
return addr;
}
#endif
static inline int sa_set_port(union sock_addr *s, u_short port)
{
switch (s->sa.sa_family) {