]> granicus.if.org Git - strace/commitdiff
Enhance error diagnostics about invalid syscalls in fault injection syntax
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 15 Jan 2018 18:16:31 +0000 (18:16 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 15 Jan 2018 18:16:31 +0000 (18:16 +0000)
* basic_filters.c (qualify_syscall_tokens): Remove "name" argument,
assume its value is "system call".
* filter.h (qualify_syscall_tokens): Remove "name" argument.
All callers updated.
* tests/qual_fault-syntax.test: Update expected output.

basic_filters.c
filter.h
filter_qualify.c
tests/qual_fault-syntax.test

index 33cf3df0b509f2863a87711d4957fcb884a339f5..d20b8809a7877654aaef405796a4da9bb6135f00 100644 (file)
@@ -197,8 +197,7 @@ qualify_syscall(const char *token, struct number_set *set)
  * according to STR specification.
  */
 void
-qualify_syscall_tokens(const char *const str, struct number_set *const set,
-                      const char *const name)
+qualify_syscall_tokens(const char *const str, struct number_set *const set)
 {
        /* Clear all sets. */
        clear_number_set_array(set, SUPPORTED_PERSONALITIES);
@@ -242,13 +241,13 @@ qualify_syscall_tokens(const char *const str, struct number_set *const set,
             token = strtok_r(NULL, ",", &saveptr)) {
                done = qualify_syscall(token, set);
                if (!done)
-                       error_msg_and_die("invalid %s '%s'", name, token);
+                       error_msg_and_die("invalid system call '%s'", token);
        }
 
        free(copy);
 
        if (!done)
-               error_msg_and_die("invalid %s '%s'", name, str);
+               error_msg_and_die("invalid system call '%s'", str);
 }
 
 /*
index fab18127872ae6d2d1b8d07987ffc496ec5fb5fc..30c2defbc95545c123a56454bde17e6e55ba581b 100644 (file)
--- a/filter.h
+++ b/filter.h
@@ -34,7 +34,6 @@ typedef int (*string_to_uint_func)(const char *);
 
 void qualify_tokens(const char *str, struct number_set *set,
                    string_to_uint_func func, const char *name);
-void qualify_syscall_tokens(const char *str, struct number_set *set,
-                           const char *name);
+void qualify_syscall_tokens(const char *str, struct number_set *set);
 
 #endif /* !STRACE_FILTER_H */
index 362857fb6758cfaeff5d2b66c6e2817bb0fc8063..ddba3d5e8ac6250b5ea1562f9a7d6c157adfa564 100644 (file)
@@ -203,7 +203,7 @@ qualify_trace(const char *const str)
 {
        if (!trace_set)
                trace_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
-       qualify_syscall_tokens(str, trace_set, "system call");
+       qualify_syscall_tokens(str, trace_set);
 }
 
 static void
@@ -211,7 +211,7 @@ qualify_abbrev(const char *const str)
 {
        if (!abbrev_set)
                abbrev_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
-       qualify_syscall_tokens(str, abbrev_set, "system call");
+       qualify_syscall_tokens(str, abbrev_set);
 }
 
 static void
@@ -219,7 +219,7 @@ qualify_verbose(const char *const str)
 {
        if (!verbose_set)
                verbose_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
-       qualify_syscall_tokens(str, verbose_set, "system call");
+       qualify_syscall_tokens(str, verbose_set);
 }
 
 static void
@@ -227,7 +227,7 @@ qualify_raw(const char *const str)
 {
        if (!raw_set)
                raw_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
-       qualify_syscall_tokens(str, raw_set, "system call");
+       qualify_syscall_tokens(str, raw_set);
 }
 
 static void
@@ -258,7 +258,7 @@ qualify_inject_common(const char *const str,
 
        struct number_set *tmp_set =
                alloc_number_set_array(SUPPORTED_PERSONALITIES);
-       qualify_syscall_tokens(name, tmp_set, description);
+       qualify_syscall_tokens(name, tmp_set);
 
        free(copy);
 
index 0cce539a906cc0b32c2fd0ca86bc4c130d2c0567..46e108b6f66fcabefa92f6848ff5eecc164e78cc 100755 (executable)
@@ -2,7 +2,7 @@
 #
 # Check -e fault= syntax.
 #
-# Copyright (c) 2016-2017 Dmitry V. Levin <ldv@altlinux.org>
+# Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -40,7 +40,7 @@ fail_with()
                "strace -e fault=$* failed to handle an argument error properly"
 }
 
-for arg in '' , ,, ,,, : :: ::: \! \!, \!: \
+for arg in , ,, ,,, \! \!, \!: \
           invalid_syscall_name \
           invalid_syscall_name:when=3 \
           -1 \!-1 \
@@ -49,7 +49,20 @@ for arg in '' , ,, ,,, : :: ::: \! \!, \!: \
           -2:when=5 \
           32767 \!32767 \
           32767:when=6 \
-          chdir:42 \!chdir:42 \
+          file,nonsense \
+          \!desc,nonsense \
+          chdir,nonsense \
+          \!chdir,nonsense \
+          1,nonsense \
+          \!1,nonsense \
+          ; do
+       $STRACE -e fault="$arg" true 2> "$LOG" &&
+               fail_with "$arg"
+       LC_ALL=C grep -F "invalid system call '" < "$LOG" > /dev/null ||
+               fail_with "$arg"
+done
+
+for arg in '' : :: ::: chdir:42 \!chdir:42 \
           chdir:42:when=7 \
           chdir:invalid \
           chdir:invalid:when=8 \
@@ -92,12 +105,6 @@ for arg in '' , ,, ,,, : :: ::: \! \!, \!: \
           chdir:when=65536:error=30 \
           chdir:when=1+65536 \
           chdir:when=1+65536:error=31 \
-          file,nonsense \
-          \!desc,nonsense \
-          chdir,nonsense \
-          \!chdir,nonsense \
-          1,nonsense \
-          \!1,nonsense \
           chdir:retval=0 \
           chdir:signal=1 \
           chdir:error=1:error=2 \