aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2026-08-04 09:55:22 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2026-08-04 09:55:22 +0000
commitddd850aa7720f77b6605599655df898b16ed74cc (patch)
tree088b0a81aae5ddd57ed6e048e263304a852e56a5 /lib
parent495826f69d96857bf0559516502e058ecab4ee4d (diff)
sys/socket.h: Fix AF_MAX
AF_MAX was always intended to be one more than the greatest allocated value. Jeff broke this in 2013. Unfortunately, a bunch of people then decided to adapt to the mistake instead of correcting it. Fixes: 863c7e45628d (" - Reserve a special AF for SDP. The one we were incorrectly using before was taken by another AF.") MFC after: 3 days Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: kevans, glebius Differential Revision: https://reviews.freebsd.org/D58597
Diffstat (limited to 'lib')
-rw-r--r--lib/libifconfig/libifconfig.c4
-rw-r--r--lib/libifconfig/libifconfig_internal.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/libifconfig/libifconfig.c b/lib/libifconfig/libifconfig.c
index bc0fcb6021b2..b450c15180db 100644
--- a/lib/libifconfig/libifconfig.c
+++ b/lib/libifconfig/libifconfig.c
@@ -81,7 +81,7 @@ ifconfig_open(void)
if (h == NULL) {
return (NULL);
}
- for (int i = 0; i <= AF_MAX; i++) {
+ for (int i = 0; i < AF_MAX; i++) {
h->sockets[i] = -1;
}
@@ -92,7 +92,7 @@ void
ifconfig_close(ifconfig_handle_t *h)
{
- for (int i = 0; i <= AF_MAX; i++) {
+ for (int i = 0; i < AF_MAX; i++) {
if (h->sockets[i] != -1) {
(void)close(h->sockets[i]);
}
diff --git a/lib/libifconfig/libifconfig_internal.c b/lib/libifconfig/libifconfig_internal.c
index c6c955debb3d..91de1ece59fb 100644
--- a/lib/libifconfig/libifconfig_internal.c
+++ b/lib/libifconfig/libifconfig_internal.c
@@ -78,7 +78,7 @@ int
ifconfig_socket(ifconfig_handle_t *h, const int addressfamily, int *s)
{
- if (addressfamily > AF_MAX) {
+ if (addressfamily >= AF_MAX) {
h->error.errtype = SOCKET;
h->error.errcode = EINVAL;
return (-1);