Blame SOURCES/0008-extensions-among-Check-call-to-fstat.patch

576484
From 3a4d59e5cb35cf2395cfd8004dd16d45dd889e11 Mon Sep 17 00:00:00 2001
576484
From: Phil Sutter <phil@nwl.cc>
576484
Date: Thu, 5 Dec 2019 16:35:51 +0100
576484
Subject: [PATCH] extensions: among: Check call to fstat()
576484
576484
If this fails, a bogus length value may be passed to mmap().
576484
576484
Fixes: 26753888720d8 ("nft: bridge: Rudimental among extension support")
576484
(cherry picked from commit 25b38bcbf2fdc019f438805c7d1ecd877af9c968)
576484
Signed-off-by: Phil Sutter <psutter@redhat.com>
576484
---
576484
 extensions/libebt_among.c | 6 +++++-
576484
 1 file changed, 5 insertions(+), 1 deletion(-)
576484
576484
diff --git a/extensions/libebt_among.c b/extensions/libebt_among.c
576484
index 2e87db3bc06fa..715d559f432c2 100644
576484
--- a/extensions/libebt_among.c
576484
+++ b/extensions/libebt_among.c
576484
@@ -6,6 +6,7 @@
576484
  * August, 2003
576484
  */
576484
 
576484
+#include <errno.h>
576484
 #include <ctype.h>
576484
 #include <fcntl.h>
576484
 #include <getopt.h>
576484
@@ -137,7 +138,10 @@ static int bramong_parse(int c, char **argv, int invert,
576484
 		if ((fd = open(optarg, O_RDONLY)) == -1)
576484
 			xtables_error(PARAMETER_PROBLEM,
576484
 				      "Couldn't open file '%s'", optarg);
576484
-		fstat(fd, &stats);
576484
+		if (fstat(fd, &stats) < 0)
576484
+			xtables_error(PARAMETER_PROBLEM,
576484
+				      "fstat(%s) failed: '%s'",
576484
+				      optarg, strerror(errno));
576484
 		flen = stats.st_size;
576484
 		/* use mmap because the file will probably be big */
576484
 		optarg = mmap(0, flen, PROT_READ | PROT_WRITE,
576484
-- 
576484
2.24.0
576484