Browse Source

[fix] pipe: prevent segfault when using "||".

Moul 4 years ago
parent
commit
94431cd8ad
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/pipe.c

+ 6 - 0
src/pipe.c

@@ -1,6 +1,7 @@
 #include "sh.h"
 
 /*
+** Check no || are present to prevent segfault
 ** Count number of pipes
 ** Malloc pipe file descriptors
 ** Create pipes
@@ -14,6 +15,11 @@ void	launch_pipe(char *all_cmd)
 	int		i;
 	char	**cmd_pipe;
 
+	if (ft_strstr(all_cmd, "||") != NULL)
+	{
+		error_message("", "I do not handle \"||\"", NULL);
+		return ;
+	}
 	pipe_nbr = count_char_str(all_cmd, '|');
 	fd = (int**)malloc(sizeof(int*) * pipe_nbr);
 	i = -1;