public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] Access02 and use of system() library function
@ 2017-03-16 14:04 Laurent GONZALEZ
  2017-03-20 11:11 ` Cyril Hrubis
  0 siblings, 1 reply; 6+ messages in thread
From: Laurent GONZALEZ @ 2017-03-16 14:04 UTC (permalink / raw)
  To: ltp

Hi list,

in order to check the actual executable mode of a file, access02 calls system() library function.

The test fails when the return value of system() is not 0. Shouldn't the return value being tested only for its sign instead (and even versus -1 only) ?

The system() function returns -1 in case of error, and the return value of the command otherwise. Even in the case the command returns non-zero value, its execution is positively checked, but access02 fails because the return value is not 0.

This corner case happens when the shell is busybox's hush. Hush uses execvp to execute the test_file3, this leads the kernel to return ENOEXEC (bad exec format). Then execvp tries to execute the shell "/bin/sh" with the name of the file "./test_file3" as argv[0]. Then busybox returns that no such an applet does exist, and terminates with error code 127.

Thanks for comments.




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

end of thread, other threads:[~2017-03-31 11:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-16 14:04 [LTP] Access02 and use of system() library function Laurent GONZALEZ
2017-03-20 11:11 ` Cyril Hrubis
2017-03-20 12:22   ` Laurent GONZALEZ
2017-03-30 14:19     ` Cyril Hrubis
2017-03-31  7:58       ` Laurent GONZALEZ
2017-03-31 11:29         ` Cyril Hrubis

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