From 70f43f7806160cf3b6b028e9b33e1e4d33a904d9 Mon Sep 17 00:00:00 2001 From: obarun <eric@obarun.org> Date: Sat, 15 Oct 2022 20:41:05 +1100 Subject: [PATCH] avoid HEAP allocation --- src/lib66/parse/parse_module.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/lib66/parse/parse_module.c b/src/lib66/parse/parse_module.c index 992b6ef5..a2c82b25 100644 --- a/src/lib66/parse/parse_module.c +++ b/src/lib66/parse/parse_module.c @@ -118,28 +118,6 @@ static void parse_module_check_name(char const *src, char const *name) log_die(LOG_EXIT_USER, "invalid directory name for module: ", name, " -- directory name must start with a '@' character") ; } -static int parse_module_ownerhome(char *store) -{ - log_flow() ; - - char const *user_home = 0 ; - int e = errno ; - struct passwd *st = getpwuid(getuid()) ; - errno = 0 ; - if (!st) { - if (!errno) errno = ESRCH ; - return 0 ; - } - user_home = st->pw_dir ; - errno = e ; - if (!user_home) - return 0 ; - - auto_strings(store, user_home, "/") ; - - return 1 ; -} - /* 0 filename undefine * -1 system error * should return at least 2 meaning :: no file define*/ @@ -292,6 +270,7 @@ static void regex_replace(stralloc *list, resolve_service_t *res) } } + stralloc_free(&frontend) ; stralloc_free(&sa) ; } @@ -507,7 +486,7 @@ void parse_module(resolve_service_t *res, resolve_service_t *ares, unsigned int } else { - if (!parse_module_ownerhome(path)) + if (!set_ownerhome_stack(path)) log_dieusys(LOG_EXIT_SYS, "unable to find the home directory of the user") ; pathlen = strlen(path) ; -- GitLab