From 0b2630f62460fe6ad227071eb34fdb466d0c0890 Mon Sep 17 00:00:00 2001 From: Alexey Khromov Date: Tue, 14 May 2024 00:52:05 +0300 Subject: [PATCH] . --- source/bforce/os_unix.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/source/bforce/os_unix.c b/source/bforce/os_unix.c index 832cf50..a8ad499 100644 --- a/source/bforce/os_unix.c +++ b/source/bforce/os_unix.c @@ -14,6 +14,8 @@ #include "includes.h" #include "confread.h" #include "logger.h" +#include +#include struct { char *name; @@ -75,17 +77,16 @@ int exec_options_parse(char *str) void exec_options_init(s_exec_options *eopt) { - char ** env; - int i; + int i = 0; memset(eopt, '\0', sizeof(s_exec_options)); eopt->umask = EXEC_DEFAULT_UMASK; - env = environ; eopt->envp[0] = NULL; - for (i=0; env[i]; i++) { - log("EXEC: Added ENV variable: %s\n", env[i]); - eopt->envp[i] = xmalloc(strlen(env[i]) + 2); - sprintf(eopt->envp[i], env[i]); - eopt->envp[i+1] = NULL; + + while(environ[i]) { + log("EXEC: Added ENV variable: %s\n", environ[i]); + eopt->envp[i] = xmalloc(strlen(environ[i]) + 2); + sprintf(eopt->envp[i], environ[i++]); + eopt->envp[i] = NULL; } }