[LTP] [PATCH 1/2] tst_rod: Use args[0] as the command name

Martin Doucha mdoucha@suse.cz
Thu Jul 28 13:42:57 CEST 2022


Using argv[1] as the command name might fail if the first argument happens
to be I/O redirection. Use args[0] which is always the first argument not
processed by tst_rod.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/lib/tst_rod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/lib/tst_rod.c b/testcases/lib/tst_rod.c
index 2f0ff902c..24c1fb668 100644
--- a/testcases/lib/tst_rod.c
+++ b/testcases/lib/tst_rod.c
@@ -130,7 +130,7 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	execvp(argv[1], args);
+	execvp(args[0], args);
 
 	/* Fall back to shell if command wasn't found */
 	FILE *sin = popen("/bin/sh", "w");
-- 
2.36.1



More information about the ltp mailing list