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