From 393ea506ab4b4eaa18a451b80e347b40089e0a3e Mon Sep 17 00:00:00 2001 From: mbuhl Date: Mon, 7 Nov 2022 22:39:13 +0000 Subject: [PATCH] Fix theoretical access to garbage stack memory in pfkey_reply for bgpd and ldpd. Found by CodeChecker. OK claudio@ --- usr.sbin/bgpd/pfkey.c | 6 +++--- usr.sbin/ldpd/pfkey.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bgpd/pfkey.c b/usr.sbin/bgpd/pfkey.c index 20c684cfd01..7918775978e 100644 --- a/usr.sbin/bgpd/pfkey.c +++ b/usr.sbin/bgpd/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.67 2022/08/17 15:15:26 claudio Exp $ */ +/* $OpenBSD: pfkey.c,v 1.68 2022/11/07 22:39:13 mbuhl Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -423,7 +423,7 @@ pfkey_read(int sd, struct sadb_msg *h) if (recv(sd, &hdr, sizeof(hdr), MSG_PEEK) != sizeof(hdr)) { if (errno == EAGAIN || errno == EINTR) - return (0); + return (1); log_warn("pfkey peek"); return (-1); } @@ -439,7 +439,7 @@ pfkey_read(int sd, struct sadb_msg *h) /* not ours, discard */ if (read(sd, &hdr, sizeof(hdr)) == -1) { if (errno == EAGAIN || errno == EINTR) - return (0); + return (1); log_warn("pfkey read"); return (-1); } diff --git a/usr.sbin/ldpd/pfkey.c b/usr.sbin/ldpd/pfkey.c index 0af77a85af4..0a4a9124db1 100644 --- a/usr.sbin/ldpd/pfkey.c +++ b/usr.sbin/ldpd/pfkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkey.c,v 1.12 2019/01/23 02:02:04 dlg Exp $ */ +/* $OpenBSD: pfkey.c,v 1.13 2022/11/07 22:39:13 mbuhl Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -253,7 +253,7 @@ pfkey_read(int sd, struct sadb_msg *h) if (recv(sd, &hdr, sizeof(hdr), MSG_PEEK) != sizeof(hdr)) { if (errno == EAGAIN || errno == EINTR) - return (0); + return (1); log_warn("pfkey peek"); return (-1); } @@ -269,7 +269,7 @@ pfkey_read(int sd, struct sadb_msg *h) /* not ours, discard */ if (read(sd, &hdr, sizeof(hdr)) == -1) { if (errno == EAGAIN || errno == EINTR) - return (0); + return (1); log_warn("pfkey read"); return (-1); } -- 2.20.1