NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: misc/57905: blocklistd.conf and ipv6



Mark Davies <mark%ecs.vuw.ac.nz@localhost> writes:

> The following reply was made to PR misc/57905; it has been noted by GNATS.
>
> From: Mark Davies <mark%ecs.vuw.ac.nz@localhost>
> To: gnats-bugs%netbsd.org@localhost
> Cc: 
> Subject: Re: misc/57905: blocklistd.conf and ipv6
> Date: Tue, 6 Feb 2024 14:28:26 +1300
>
>  On 06/02/2024 02:10, Sunil Nimmagadda wrote:
>  >   If I understood the syntax for location correctly, it should be
>  >   [2404:2000::]/32 i.e., the mask should be after the enclosing square
>  >   brackets for an IPv6 address.
>  
>  I thought I'd tried that at some point, but anyway ...
>  
>  >   Also verified that inet_pton(3) wouldn't parse 2404:2000::/32. This
>  >   patch checks if inet_pton(3) parsed address successfully and also
>  >   rectifies the line number reporting. Compile tested only, can't run IPv6
>  >   atm.
>  
>  confirmed that your patch gets an error reported for [2404:2000::/32] 
>  and fixes the line number reporting, but with [2404:2000::]/32 I still get
>  
>  Feb  6 14:22:27 smb2 blocklistd[3834]: conf_getnum: 
>  /etc/blocklistd.conf, 9: Bad number for service []
>  
>  
>  cheers
>  mark
>  

IPv6 case needs to set the port as "*" (FSTAR) when not specified in
the config for the conf_getport() to parse it correctly. Updated diff...

diff -r 1837af7fedd4 external/bsd/blocklist/bin/conf.c
--- a/external/bsd/blocklist/bin/conf.c	Sat Feb 03 22:40:29 2024 +0000
+++ b/external/bsd/blocklist/bin/conf.c	Sat Feb 03 17:25:56 2024 +0530
@@ -261,7 +261,7 @@
 		if (debug)
 			(*lfun)(LOG_DEBUG, "%s: host6 %s", __func__, p);
 		if (strcmp(p, "*") != 0) {
-			if (inet_pton(AF_INET6, p, &sin6->sin6_addr) == -1)
+			if (inet_pton(AF_INET6, p, &sin6->sin6_addr) != 1)
 				goto out;
 			sin6->sin6_family = AF_INET6;
 #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
@@ -269,6 +269,8 @@
 #endif
 			port = &sin6->sin6_port;
 		}
+		if (strlen(pstr) == 0)
+			pstr = "*";
 	} else if (pstr != p || strchr(p, '.') || conf_is_interface(p)) {
 		if (pstr == p)
 			pstr = "*";
@@ -311,7 +313,7 @@
 		*port = htons((in_port_t)c->c_port);
 	return 0;
 out:
-	(*lfun)(LOG_ERR, "%s: %s, %zu: Bad address [%s]", __func__, f, l, pstr);
+	(*lfun)(LOG_ERR, "%s: %s, %zu: Bad address [%s]", __func__, f, l, p);
 	return -1;
 out1:
 	(*lfun)(LOG_ERR, "%s: %s, %zu: Can't specify mask %d with "
@@ -1172,7 +1174,7 @@
 		return;
 	}
 
-	lineno = 1;
+	lineno = 0;
 
 	confset_init(&rc);
 	confset_init(&lc);


Home | Main Index | Thread Index | Old Index