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