Skip to content

Commit 48accde

Browse files
committed
Move the getifaddrs() call below the interface checks that can cause
update_iface() to return early to avoid leaking the allocated memory if any of the checks fail. ok florian@ bluhm@ dlg@
1 parent 57bde5d commit 48accde

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sbin/dhcp6leased/frontend.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: frontend.c,v 1.21 2025/04/27 16:22:33 florian Exp $ */
1+
/* $OpenBSD: frontend.c,v 1.22 2025/06/19 10:28:41 jmatthew Exp $ */
22

33
/*
44
* Copyright (c) 2017, 2021, 2024 Florian Obser <[email protected]>
@@ -559,9 +559,6 @@ update_iface(uint32_t if_index)
559559
int flags;
560560
char ifnamebuf[IF_NAMESIZE], *if_name;
561561

562-
if (getifaddrs(&ifap) != 0)
563-
fatal("getifaddrs");
564-
565562
if ((if_name = if_indextoname(if_index, ifnamebuf)) == NULL)
566563
return;
567564

@@ -571,6 +568,9 @@ update_iface(uint32_t if_index)
571568
if (find_iface_conf(&frontend_conf->iface_list, if_name) == NULL)
572569
return;
573570

571+
if (getifaddrs(&ifap) != 0)
572+
fatal("getifaddrs");
573+
574574
memset(&ifinfo, 0, sizeof(ifinfo));
575575
ifinfo.if_index = if_index;
576576
ifinfo.link_state = -1;

0 commit comments

Comments
 (0)