[PATCH nft v2 1/2] main: Validate the number of numeric options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The number of numeric options influences the behavior and the user
should be warned if a invalid number is used.

Signed-off-by: Elise Lennion <elise.lennion@xxxxxxxxx>
---

 v2: Was split from a bigger patch. Now an error is triggered when a
 invalid number of numeric options is used, instead of allowing it and
 using the closer valid number.

 src/main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c
index 6ba752b..48a813d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -288,7 +288,12 @@ int main(int argc, char * const *argv)
 			include_paths[num_include_paths++] = optarg;
 			break;
 		case OPT_NUMERIC:
-			numeric_output++;
+			if (++numeric_output > NUMERIC_ALL) {
+				fprintf(stderr, "Too many numeric options "
+						"used, max. %u\n",
+					NUMERIC_ALL);
+				exit(NFT_EXIT_FAILURE);
+			}
 			break;
 		case OPT_STATELESS:
 			stateless_output++;
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux