Skip to content

Commit 5846cde

Browse files
committed
get_net_ifs: fix memory leak in SIOCGIFCONF version
Found by the ZeroPath AI Security Engineer <https://zeropath.com>
1 parent 6a1fe42 commit 5846cde

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/net_ifs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,10 @@ get_net_ifs(char **addrinfo_out)
654654
struct sockaddr_in6 *sin6;
655655
# endif
656656
char addrstr[INET6_ADDRSTRLEN], maskstr[INET6_ADDRSTRLEN];
657-
char *addrinfo = NULL;
657+
char *cp, addrinfo = NULL;
658658
int i, n, sock, sock4, sock6 = -1;
659659
int num_interfaces = 0;
660660
size_t ailen, buflen;
661-
char *cp, *ifconf_buf = NULL;
662661
debug_decl(get_net_ifs, SUDO_DEBUG_NETIF);
663662

664663
if (!sudo_conf_probe_interfaces())
@@ -859,7 +858,7 @@ get_net_ifs(char **addrinfo_out)
859858
free(addrinfo);
860859
num_interfaces = -1;
861860
done:
862-
free(ifconf_buf);
861+
free(ifconf.ifc_buf);
863862
if (sock4 != -1)
864863
close(sock4);
865864
if (sock6 != -1)

0 commit comments

Comments
 (0)