From: claudio Date: Mon, 9 Oct 2023 07:11:20 +0000 (+0000) Subject: Fix return value confusion of sa_cmp() by renaming the function sa_equal(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2bf4796c75d83d0d170eca2c0aea205a8d6ac12f;p=openbsd Fix return value confusion of sa_cmp() by renaming the function sa_equal(). The code in get_alternate_addr() checked for sa_cmp() == 0 but actually sa_cmp() returned 1 for equal addrs. So rename the function to sa_equal() to make it clear that a true return value means equality. Found by Asa Yeamans (enigma2e at rivin net) OK tb@ --- diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 86dadcfee70..30d40153643 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.447 2023/08/04 09:20:12 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.448 2023/10/09 07:11:20 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer @@ -1204,7 +1204,7 @@ session_setup_socket(struct peer *p) /* compare two sockaddrs by converting them into bgpd_addr */ static int -sa_cmp(struct sockaddr *a, struct sockaddr *b) +sa_equal(struct sockaddr *a, struct sockaddr *b) { struct bgpd_addr ba, bb; @@ -1223,8 +1223,7 @@ get_alternate_addr(struct sockaddr *sa, struct bgpd_addr *alt) fatal("getifaddrs"); for (match = ifap; match != NULL; match = match->ifa_next) - if (match->ifa_addr != NULL && - sa_cmp(sa, match->ifa_addr) == 0) + if (match->ifa_addr != NULL && sa_equal(sa, match->ifa_addr)) break; if (match == NULL) {