git: 2d9d97e66e9e - main - ifconfig: improve error checking for carp peer6

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Thu, 18 May 2023 16:01:22 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=2d9d97e66e9e29de128c21cb676b9661df20dede

commit 2d9d97e66e9e29de128c21cb676b9661df20dede
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-05-17 19:39:42 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-05-18 15:47:03 +0000

    ifconfig: improve error checking for carp peer6
    
    getaddrinfo() returns 0 if it succeeded, but it's not guaranteed to
    return 1 on error. Check for success rather than for one specific error.
    
    Without this fix commands such as `ifconfig bnxt1 inet6 add vhid 1 peer6
    2001:db8::1/64` would segfault ifconfig.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sbin/ifconfig/carp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sbin/ifconfig/carp.c b/sbin/ifconfig/carp.c
index aab5f2985328..2a2d8ce407ab 100644
--- a/sbin/ifconfig/carp.c
+++ b/sbin/ifconfig/carp.c
@@ -237,7 +237,7 @@ setcarp_peer6(const char *val, int d, int s, const struct afswtch *afp)
 	hints.ai_family = AF_INET6;
 	hints.ai_flags = AI_NUMERICHOST;
 
-	if (getaddrinfo(val, NULL, &hints, &res) == 1)
+	if (getaddrinfo(val, NULL, &hints, &res) != 0)
 		errx(1, "Invalid IPv6 address %s", val);
 
 	memcpy(&carp_addr6, &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr,