summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryasuoka <yasuoka@openbsd.org>2015-06-23 06:59:54 +0000
committeryasuoka <yasuoka@openbsd.org>2015-06-23 06:59:54 +0000
commit3a6fc3410e0d0c768bb4489c48248cfa629d8ef7 (patch)
tree679d668c87376eb7e1f55b3fc6e4e1d02b4bd283
parentFix the links to pppx(4). (diff)
downloadwireguard-openbsd-3a6fc3410e0d0c768bb4489c48248cfa629d8ef7.tar.xz
wireguard-openbsd-3a6fc3410e0d0c768bb4489c48248cfa629d8ef7.zip
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.
-rw-r--r--usr.sbin/npppd/l2tp/l2tpd.c6
-rw-r--r--usr.sbin/npppd/pptp/pptpd.c11
2 files changed, 8 insertions, 9 deletions
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 <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
@@ -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 <sys/types.h>
#include <sys/socket.h>
@@ -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");