diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-11 16:25:51 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-11 16:25:51 +0200 |
commit | b2ffd2aeb4a91501ae7931cb43a9679b01eb0351 (patch) | |
tree | 3db47f5b3baed19f9a103ba124098560ddf7ddc4 /src/s_com.c | |
parent | TODO update (diff) | |
download | 42-minishell-b2ffd2aeb4a91501ae7931cb43a9679b01eb0351.tar.gz 42-minishell-b2ffd2aeb4a91501ae7931cb43a9679b01eb0351.tar.bz2 42-minishell-b2ffd2aeb4a91501ae7931cb43a9679b01eb0351.tar.xz 42-minishell-b2ffd2aeb4a91501ae7931cb43a9679b01eb0351.tar.zst 42-minishell-b2ffd2aeb4a91501ae7931cb43a9679b01eb0351.zip |
Nice fix
Diffstat (limited to '')
-rw-r--r-- | src/s_com.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/s_com.c b/src/s_com.c index 6d6ee09..277d996 100644 --- a/src/s_com.c +++ b/src/s_com.c @@ -12,7 +12,9 @@ #include <libft.h> #include <stdlib.h> +#include <limits.h> +#include "d_define.h" #include "f_fail.h" #include "p_args.h" #include "p_lblock.h" @@ -98,6 +100,7 @@ void t_com *s_com_new(char word[], t_msh *msh) { + char nword[ARG_MAX]; t_com *com; char **words; @@ -109,12 +112,12 @@ t_com com->rdrfd = 0; com->rdrpath = NULL; com->env_fork = NULL; - if (p_get_redir(word, &com) != 0) + nword[0] = C_NUL; + ft_strlcpy(nword, word, ARG_MAX); + if (p_get_redir(nword, &com) != 0) return (NULL); - if ((word = p_subst_vars(word, msh)) == NULL) - return (NULL); - msh->curr->lblock = word; - if ((words = p_split_args(word, com->redir)) == NULL) + p_subst_vars(nword, msh); + if ((words = p_split_args(nword, com->redir)) == NULL) return (NULL); if ((words = p_subst_home(words, msh)) == NULL) return (NULL); |