[PATCH] lib: fwts_args: fix arg parameter sanity range checking

Colin King colin.king at canonical.com
Fri Jan 20 10:54:20 UTC 2017


From: Colin Ian King <colin.king at canonical.com>

An earlier commit remove the arg parameter sanity range checking
which should be re-instated. Add the code back.

Fixes: 973a296cad30 ("v2 - lib: fwts_args: handle cases to set optarg_handler for long options.")
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/lib/src/fwts_args.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/lib/src/fwts_args.c b/src/lib/src/fwts_args.c
index 5d47547..fec656f 100644
--- a/src/lib/src/fwts_args.c
+++ b/src/lib/src/fwts_args.c
@@ -212,6 +212,16 @@ int fwts_args_parse(fwts_framework *fw, const int argc, char * const argv[])
 		}
 	}
 
+	/* We've collected all the args, now sanity check the values */
+
+	fwts_list_foreach(item, &options_list) {
+		options_table = fwts_list_data(fwts_options_table *, item);
+		if (options_table->optarg_check != NULL) {
+			ret = options_table->optarg_check(fw);
+			if (ret != FWTS_OK)
+				break;
+		}
+	}
 exit:
 	free(short_options);
 	free(long_options);
-- 
2.10.2




More information about the fwts-devel mailing list