From 44f2793a9da4e456f6ad5445a60f819009a20035 Mon Sep 17 00:00:00 2001 From: remi Date: Sun, 15 Dec 2019 20:51:39 +0000 Subject: Clear r_list if the interface is passive. Additionaly move the check for passive interface a bit further up so that the function can return earlier. Memory leak observed and reported by Jason Tubnor. OK benno@ --- usr.sbin/ripd/message.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/usr.sbin/ripd/message.c b/usr.sbin/ripd/message.c index 62d2fc33578..be56650f6fd 100644 --- a/usr.sbin/ripd/message.c +++ b/usr.sbin/ripd/message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: message.c,v 1.14 2019/12/09 20:49:40 remi Exp $ */ +/* $OpenBSD: message.c,v 1.15 2019/12/15 20:51:39 remi Exp $ */ /* * Copyright (c) 2006 Michele Marchetto @@ -105,15 +105,15 @@ send_triggered_update(struct iface *iface, struct rip_route *rr) u_int16_t afi, route_tag; u_int32_t address, netmask, nexthop, metric; + if (iface->passive) + return (0); + inet_aton(ALL_RIP_ROUTERS, &dst.sin_addr); dst.sin_port = htons(RIP_PORT); dst.sin_family = AF_INET; dst.sin_len = sizeof(struct sockaddr_in); - if (iface->passive) - return (0); - if ((buf = ibuf_open(iface->mtu - sizeof(struct ip) - sizeof(struct udphdr))) == NULL) fatal("send_triggered_update"); @@ -166,13 +166,15 @@ send_request(struct packet_head *r_list, struct iface *i, struct nbr *nbr) port = htons(RIP_PORT); } + if (iface->passive) { + clear_list(r_list); + return (0); + } + dst.sin_port = port; dst.sin_family = AF_INET; dst.sin_len = sizeof(struct sockaddr_in); - if (iface->passive) - return (0); - while (!TAILQ_EMPTY(r_list)) { if ((buf = ibuf_open(iface->mtu - sizeof(struct ip) - sizeof(struct udphdr))) == NULL) @@ -240,13 +242,15 @@ send_response(struct packet_head *r_list, struct iface *i, struct nbr *nbr) port = htons(RIP_PORT); } + if (iface->passive) { + clear_list(r_list); + return (0); + } + dst.sin_port = port; dst.sin_family = AF_INET; dst.sin_len = sizeof(struct sockaddr_in); - if (iface->passive) - return (0); - while (!TAILQ_EMPTY(r_list)) { if ((buf = ibuf_open(iface->mtu - sizeof(struct ip) - sizeof(struct udphdr))) == NULL) -- cgit v1.2.3-59-g8ed1b