Skip to contentSkip to conversation

main: Validate the number of numeric options

PATCH Applied Elise Lennion 2 participants 2 messages Feb 2, 2017 – Feb 5, 2017 netfilter

lore
Share & tools
lore
#0 lore raw

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

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

---

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(-)
src/main.c +6 -1
index 6ba752b..48a813d 100644
@@ -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++;
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw
Quoted 2 lines · Elise Lennion

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

Applied, thanks Elise.