summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Wood <thomas.wood@intel.com>2015-01-26 16:59:53 +0000
committerThomas Wood <thomas.wood@intel.com>2015-02-09 14:39:41 +0000
commit2b05ecfb0625ddf4b8cced18c471063aa23e2768 (patch)
tree122b65f639f9eb3e9dedcbe1096a928f8b3de2e0 /lib
parent61737903ad4d4423516a41538d1ce4cf7287da0e (diff)
lib: validate subtest names
Subtest names should only contain '-', '_' and alphanumeric characters. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_core.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c
index bc588e2c..d74f6f8f 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -54,6 +54,7 @@
#include <termios.h>
#include <errno.h>
#include <time.h>
+#include <ctype.h>
#include "drmtest.h"
#include "intel_chipset.h"
@@ -693,10 +694,21 @@ void igt_simple_init_parse_opts(int argc, char **argv,
*/
bool __igt_run_subtest(const char *subtest_name)
{
+ int i;
+
assert(!in_subtest);
assert(!in_fixture);
assert(test_with_subtests);
+ /* check the subtest name only contains a-z, A-Z, 0-9, '-' and '_' */
+ for (i = 0; subtest_name[i] != '\0'; i++)
+ if (subtest_name[i] != '_' && subtest_name[i] != '-'
+ && !isalnum(subtest_name[i])) {
+ igt_critical("Invalid subtest name \"%s\".\n",
+ subtest_name);
+ igt_exit();
+ }
+
if (list_subtests) {
printf("%s\n", subtest_name);
return false;