Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] tst_rod: Use args[0] as the command name
@ 2022-07-28 11:42 Martin Doucha
  2022-07-28 11:42 ` [LTP] [PATCH 2/2] tst_rod: Fail on directory change commands Martin Doucha
  2022-08-02 14:49 ` [LTP] [PATCH 1/2] tst_rod: Use args[0] as the command name Cyril Hrubis
  0 siblings, 2 replies; 9+ messages in thread
From: Martin Doucha @ 2022-07-28 11:42 UTC (permalink / raw)
  To: ltp

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-08-31 12:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-28 11:42 [LTP] [PATCH 1/2] tst_rod: Use args[0] as the command name Martin Doucha
2022-07-28 11:42 ` [LTP] [PATCH 2/2] tst_rod: Fail on directory change commands Martin Doucha
2022-07-28 11:49   ` Martin Doucha
2022-08-02 14:55     ` Cyril Hrubis
2022-08-16 12:51       ` Petr Vorel
2022-08-02 14:53   ` Cyril Hrubis
2022-08-31 12:38   ` Cyril Hrubis
2022-08-02 14:49 ` [LTP] [PATCH 1/2] tst_rod: Use args[0] as the command name Cyril Hrubis
2022-08-16 12:40   ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox