From c80b4e513eaa39e3a132b4bb47237e4673314eca Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 27 Aug 2020 15:15:21 +0200 Subject: Fuck this shit --- src/e_externs.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/e_externs.c') diff --git a/src/e_externs.c b/src/e_externs.c index 9e2f8f4..4cc63e1 100644 --- a/src/e_externs.c +++ b/src/e_externs.c @@ -29,10 +29,9 @@ static void e_extern_child(const char *fullpath, - t_com *ptr, - t_msh *msh) + t_com *ptr, + t_msh *msh) { - dup_redirs(ptr, msh); if (execve(fullpath, ptr->argv, msh->envp) == -1) { f_exec(fullpath); @@ -59,7 +58,7 @@ static void } static void - exec_path(const char fullpath[], + e_exec_path(const char fullpath[], t_com *ptr, t_msh *msh) { @@ -95,7 +94,7 @@ void { if ((fullpath = ft_strdup(ptr->bin)) == NULL) return ; - exec_path(fullpath, ptr, msh); + e_exec_path(fullpath, ptr, msh); ft_memdel((void*)&fullpath); return ; } @@ -109,7 +108,7 @@ void } else { - exec_path(fullpath, ptr, msh); + e_exec_path(fullpath, ptr, msh); ft_memdel((void*)&fullpath); } } -- cgit v1.2.3 From 3a09e7ae69c3eb1fc3d1f8dfa25f7376ca066e86 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 27 Aug 2020 15:33:35 +0200 Subject: Freed leaks --- src/e_externs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/e_externs.c') diff --git a/src/e_externs.c b/src/e_externs.c index 4cc63e1..253d758 100644 --- a/src/e_externs.c +++ b/src/e_externs.c @@ -36,7 +36,7 @@ static void { f_exec(fullpath); ft_memdel((void*)&fullpath); - u_eof_stdin(); + u_eof_fd(msh->fd); s_line_clear(&msh->curr); s_destroy(msh); exit(errno); -- cgit v1.2.3 From ca2e36781039eb7e9901ccde395600e7af87ff4f Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 15 Sep 2020 19:59:41 +0200 Subject: Huge fixes and stack stuff --- src/e_externs.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'src/e_externs.c') diff --git a/src/e_externs.c b/src/e_externs.c index 253d758..8761986 100644 --- a/src/e_externs.c +++ b/src/e_externs.c @@ -16,15 +16,18 @@ #include #include #include +#include #include #include "b_export_next.h" -#include "e_externs_next.h" +#include "d_define.h" #include "f_fail.h" #include "m_redirs.h" +#include "s_com.h" #include "s_destroy.h" #include "s_line.h" #include "s_struct.h" +#include "u_path.h" #include "u_utils.h" static void @@ -34,9 +37,9 @@ static void { if (execve(fullpath, ptr->argv, msh->envp) == -1) { - f_exec(fullpath); - ft_memdel((void*)&fullpath); + f_exec(fullpath, ptr->bin); u_eof_fd(msh->fd); + s_com_destroy(&msh->com); s_line_clear(&msh->curr); s_destroy(msh); exit(errno); @@ -83,33 +86,20 @@ static void } } -void - e_extern(t_com *ptr, - t_msh *msh) +void e_extern(t_com *ptr, t_msh *msh) { - char **envpath; - char *fullpath; + char fullpath[PATH_MAX]; + fullpath[0] = C_NUL; if (ft_ischarset("./", ptr->bin[0]) == TRUE) { - if ((fullpath = ft_strdup(ptr->bin)) == NULL) - return ; + ft_strlcpy(fullpath, ptr->bin, PATH_MAX); e_exec_path(fullpath, ptr, msh); - ft_memdel((void*)&fullpath); return ; } - else if ((envpath = get_env_path(msh)) != NULL) + else { - fullpath = search_in_path(ptr->bin, envpath, msh); - ft_delwords(envpath); - if (fullpath == NULL) - { - f_fail_command_not_found(ptr->bin, msh); - } - else - { - e_exec_path(fullpath, ptr, msh); - ft_memdel((void*)&fullpath); - } + u_search_in_path(fullpath, ptr->bin, PATH_MAX, msh); + e_exec_path(fullpath, ptr, msh); } } -- cgit v1.2.3