Subject: bug in ppp-2.3.11 (inet_pton error check)
To: mrg@eterna.com.au, Paul Mackerras <paulus@cs.anu.edu.au>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: tech-net
Date: 01/20/2000 14:02:57
	Hello, sorry if I'm writing to wrong address, you are listed as
	maintainer (or responsible person for netbsd integration) of pppd.

	while looking at IPv6 ppp support code, I've found a bug.
	inet_pton() can return 1, 0 or -1 (see manpage).  For success/error
	check, "!= 1" (or "== 1" in some cases) should be used.
	"== 0" will not catch -1 case.

	A patch against 2.3.11 is attached.

itojun


--- pppd/ipv6cp.c-	Thu Jan 20 14:00:02 2000
+++ pppd/ipv6cp.c	Thu Jan 20 14:00:13 2000
@@ -293,7 +293,7 @@
     if (comma != arg) {
 	*comma = '\0';
 
-	if (inet_pton(AF_INET6, arg, &addr) == 0 || !VALIDID(addr)) {
+	if (inet_pton(AF_INET6, arg, &addr) != 1 || !VALIDID(addr)) {
 	    option_error("Illegal interface identifier (local): %s", arg);
 	    return 0;
 	}
@@ -307,7 +307,7 @@
      * If comma last character, the no remote identifier
      */
     if (*comma != 0 && *++comma != '\0') {
-	if (inet_pton(AF_INET6, comma, &addr) == 0 || !VALIDID(addr)) {
+	if (inet_pton(AF_INET6, comma, &addr) != 1 || !VALIDID(addr)) {
 	    option_error("Illegal interface identifier (remote): %s", comma);
 	    return 0;
 	}