* [yocto][ptest-runner 1/2] utils.c: get_available_ptests fix security flags compilation
@ 2024-01-27 19:23 Anibal Limon
2024-01-27 19:23 ` [yocto][ptest-runner 2/2] utils: run_child fix security flags build Anibal Limon
0 siblings, 1 reply; 2+ messages in thread
From: Anibal Limon @ 2024-01-27 19:23 UTC (permalink / raw)
To: yocto; +Cc: richard.purdie, JPEWhacker, randy.macleod, Anibal Limon
When get_available_ptests uses realpath to support symlinks, this is
expected to not fail because usage of stack memory, if fails prints the
error and exit.
Signed-off-by: Anibal Limon <anibal@limonsoftware.com>
---
utils.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/utils.c b/utils.c
index 59b8b77..54394cc 100644
--- a/utils.c
+++ b/utils.c
@@ -118,7 +118,10 @@ get_available_ptests(const char *dir)
int saved_errno = -1; /* Initalize to invalid errno. */
char realdir[PATH_MAX];
- realpath(dir, realdir);
+ if (realpath(dir, realdir) == NULL) {
+ fprintf(stderr, "ERROR: get_available_ptests failed to get realpath, %s\n", strerror(errno));
+ exit(1);
+ }
do
{
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [yocto][ptest-runner 2/2] utils: run_child fix security flags build
2024-01-27 19:23 [yocto][ptest-runner 1/2] utils.c: get_available_ptests fix security flags compilation Anibal Limon
@ 2024-01-27 19:23 ` Anibal Limon
0 siblings, 0 replies; 2+ messages in thread
From: Anibal Limon @ 2024-01-27 19:23 UTC (permalink / raw)
To: yocto; +Cc: richard.purdie, JPEWhacker, randy.macleod, Anibal Limon
Move chdir outside run_child to better handle when fails output an error
message plus remove the need to strdup inside run_child (already have
ptest_dir).
Signed-off-by: Anibal Limon <anibal@limonsoftware.com>
---
utils.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/utils.c b/utils.c
index 54394cc..472520f 100644
--- a/utils.c
+++ b/utils.c
@@ -327,7 +327,6 @@ static inline void
run_child(char *run_ptest, int fd_stdout, int fd_stderr)
{
char *const argv[2] = {run_ptest, NULL};
- chdir(dirname(strdup(run_ptest)));
dup2(fd_stdout, STDOUT_FILENO);
// XXX: Redirect stderr to stdout to avoid buffer ordering problems.
@@ -466,7 +465,11 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
fprintf(fp, "ERROR: Unable to attach to controlling tty, %s\n", strerror(errno));
}
- run_child(p->run_ptest, pipefd_stdout[PIPE_WRITE], pipefd_stderr[PIPE_WRITE]);
+ if (chdir(ptest_dir) == -1) {
+ fprintf(fp, "ERROR: Unable to chdir(%s), %s\n", ptest_dir, strerror(errno));
+ } else {
+ run_child(p->run_ptest, pipefd_stdout[PIPE_WRITE], pipefd_stderr[PIPE_WRITE]);
+ }
} else {
bool timedout = false;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-27 19:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-27 19:23 [yocto][ptest-runner 1/2] utils.c: get_available_ptests fix security flags compilation Anibal Limon
2024-01-27 19:23 ` [yocto][ptest-runner 2/2] utils: run_child fix security flags build Anibal Limon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox