From b6b00dd55e035bfbe311a527b567962ffa77ee43 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 26 Jun 2024 18:18:37 +0200 Subject: Merging upstream version 1:4.15.2. Signed-off-by: Daniel Baumann --- lib/run_part.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'lib/run_part.c') diff --git a/lib/run_part.c b/lib/run_part.c index bce11d3..670d815 100644 --- a/lib/run_part.c +++ b/lib/run_part.c @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -8,9 +10,12 @@ #include #include #include + +#include "alloc.h" #include "run_part.h" #include "shadowlog_internal.h" + int run_part (char *script_path, const char *name, const char *action) { int pid; @@ -53,25 +58,22 @@ int run_parts (const char *directory, const char *name, const char *action) } for (n=0; nd_name) + 2; - char *s = (char*)malloc(path_length); - if (!s) { - printf ("could not allocate memory\n"); + if (asprintf(&s, "%s/%s", directory, namelist[n]->d_name) == -1) { + fprintf(stderr, "could not allocate memory\n"); for (; nd_name); execute_result = 0; if (stat (s, &sb) == -1) { perror ("stat"); - free (s); + free(s); for (; n