From 32af7c981e230597b3a25094306ae43e423c52e1 Mon Sep 17 00:00:00 2001 From: YASUOKA Masahiko Date: Tue, 23 Jun 2015 06:59:55 +0000 Subject: Fix the problem when npppd receives a zero length 1701/udp packet. If it receives such packets when the errno is not EAGAIN or EINTR, it had closed all L2TP sessions and stoppped the L2TP server. Also fix the receiving GRE packet since it potentially has the same problem. --- usr.sbin/npppd/l2tp/l2tpd.c | 6 +++--- usr.sbin/npppd/pptp/pptpd.c | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/npppd/l2tp/l2tpd.c b/usr.sbin/npppd/l2tp/l2tpd.c index f1e9d74a9d6..664fd944aa7 100644 --- a/usr.sbin/npppd/l2tp/l2tpd.c +++ b/usr.sbin/npppd/l2tp/l2tpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: l2tpd.c,v 1.15 2014/05/07 01:16:15 tedu Exp $ */ +/* $OpenBSD: l2tpd.c,v 1.16 2015/06/23 06:59:54 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ /**@file L2TP(Layer Two Tunneling Protocol "L2TP") / RFC2661 */ -/* $Id: l2tpd.c,v 1.15 2014/05/07 01:16:15 tedu Exp $ */ +/* $Id: l2tpd.c,v 1.16 2015/06/23 06:59:54 yasuoka Exp $ */ #include #include #include @@ -632,7 +632,7 @@ l2tpd_io_event(int fd, short evtype, void *ctx) if ((sz = recvfromto(_this->sock, buf, sizeof(buf), 0, (struct sockaddr *)&peer, &peerlen, - (struct sockaddr *)&sock, &socklen)) <= 0) { + (struct sockaddr *)&sock, &socklen)) == -1) { #endif if (errno == EAGAIN || errno == EINTR) break; diff --git a/usr.sbin/npppd/pptp/pptpd.c b/usr.sbin/npppd/pptp/pptpd.c index 489ba324d09..61b92a7bc89 100644 --- a/usr.sbin/npppd/pptp/pptpd.c +++ b/usr.sbin/npppd/pptp/pptpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pptpd.c,v 1.25 2015/01/19 01:48:59 deraadt Exp $ */ +/* $OpenBSD: pptpd.c,v 1.26 2015/06/23 06:59:54 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -25,12 +25,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* $Id: pptpd.c,v 1.25 2015/01/19 01:48:59 deraadt Exp $ */ +/* $Id: pptpd.c,v 1.26 2015/06/23 06:59:54 yasuoka Exp $ */ /**@file * This file provides a implementation of PPTP daemon. Currently it * provides functions for PAC (PPTP Access Concentrator) only. - * $Id: pptpd.c,v 1.25 2015/01/19 01:48:59 deraadt Exp $ + * $Id: pptpd.c,v 1.26 2015/06/23 06:59:54 yasuoka Exp $ */ #include #include @@ -674,9 +674,8 @@ pptpd_gre_io_event(int fd, short evmask, void *ctx) /* read till bloked */ peerlen = sizeof(peer); if ((sz = recvfrom(listener->sock_gre, pkt, sizeof(pkt), - 0, (struct sockaddr *)&peer, &peerlen)) <= 0) { - if (sz < 0 && - (errno == EAGAIN || errno == EINTR)) + 0, (struct sockaddr *)&peer, &peerlen)) == -1) { + if (errno == EAGAIN || errno == EINTR) break; pptpd_log(_this, LOG_INFO, "read(GRE) failed: %m"); -- cgit v1.2.3