diff --git a/ipl_tools/Makefile b/ipl_tools/Makefile index c5e99787..fe090417 100644 --- a/ipl_tools/Makefile +++ b/ipl_tools/Makefile @@ -4,6 +4,8 @@ libs = $(rootdir)/libutil/libutil.a all: chreipl lsreipl chshut lsshut +libs = $(rootdir)/libutil/libutil.a + objects = main.o ccw.o fcp.o system.o shutdown.o \ cmd_lsshut.o cmd_chshut.o cmd_lsreipl.o cmd_chreipl.o proc.o diff --git a/ipl_tools/cmd_chreipl.c b/ipl_tools/cmd_chreipl.c index 5e59199b..50cccf4e 100644 --- a/ipl_tools/cmd_chreipl.c +++ b/ipl_tools/cmd_chreipl.c @@ -303,19 +303,21 @@ static int set_reipl_type(const char *dev_name) static int get_chreipl_helper_cmd(dev_t dev, char cmd[PATH_MAX]) { - char chreipl_helper[PATH_MAX]; + char *chreipl_helper; struct proc_dev_entry pde; if (proc_dev_get_entry(dev, 1, &pde) != 0) return -1; - snprintf(chreipl_helper, PATH_MAX, - "%s/%s.%s", TOOLS_LIBDIR, "chreipl_helper", pde.name); + util_asprintf(&chreipl_helper, + "%s/%s.%s", TOOLS_LIBDIR, "chreipl_helper", pde.name); if (access(chreipl_helper, X_OK) != 0) { proc_dev_free_entry(&pde); + free(chreipl_helper); return -1; } sprintf(cmd, "%s %d:%d", chreipl_helper, major(dev), minor(dev)); proc_dev_free_entry(&pde); + free(chreipl_helper); return 0; } diff --git a/ipl_tools/system.c b/ipl_tools/system.c index 41121378..f3f511d3 100644 --- a/ipl_tools/system.c +++ b/ipl_tools/system.c @@ -9,6 +9,7 @@ * it under the terms of the MIT license. See LICENSE for details. */ +#include "lib/util_libc.h" #include "ipl_tools.h" /* @@ -81,10 +82,11 @@ void read_str(char *string, const char *path, size_t len) */ void read_fw_str(char *string, const char *file, size_t len) { - char path[PATH_MAX]; + char *path; - snprintf(path, sizeof(path), "/sys/firmware/%s", file); - return read_str(string, path, len); + util_asprintf(&path, "/sys/firmware/%s", file); + read_str(string, path, len); + free(path); } /*