biralavor / 42_minishell

minishell, a 42 school team project to rebuild a tiny bash, using C language. Build with @Thais-Malheiros
MIT License
3 stars 0 forks source link

fix leak at EXPORT with arg plus binary command #535

Closed biralavor closed 3 weeks ago

biralavor commented 3 weeks ago

Command:

export z=a && ls

<<< Born Again (mini) SHell >>>$ export z=a && ls
==127995== Syscall param execve(envp) points to unaddressable byte(s)
==127995==    at 0x49A308B: execve (syscall-template.S:120)
==127995==    by 0x1117ED: fork_and_execve (50.command_runner.c:30)
==127995==    by 0x111962: command_runner (50.command_runner.c:71)
==127995==    by 0x10E473: preprocessing_for_command_runner (29.manage_single_cmd.c:38)
==127995==    by 0x10E424: manage_single_command (29.manage_single_cmd.c:27)
==127995==    by 0x10D76D: tree_execution (23.tree_execution.c:30)
==127995==    by 0x10D885: manage_and (25.manage_or_and.c:26)
==127995==    by 0x10D6F2: tree_execution (23.tree_execution.c:22)
==127995==    by 0x10A937: loop_routine (05.loop_routine.c:47)
==127995==    by 0x109E78: main (01.main.c:33)
==127995==  Address 0x4b62d98 is 0 bytes after a block of size 392 alloc'd
==127995==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==127995==    by 0x112023: ft_calloc (ft_calloc.c:34)
==127995==    by 0x1119AA: convert_envs_to_array (51.command_runner_utils.c:25)
==127995==    by 0x111774: fork_and_execve (50.command_runner.c:20)
==127995==    by 0x111962: command_runner (50.command_runner.c:71)
==127995==    by 0x10E473: preprocessing_for_command_runner (29.manage_single_cmd.c:38)
==127995==    by 0x10E424: manage_single_command (29.manage_single_cmd.c:27)
==127995==    by 0x10D76D: tree_execution (23.tree_execution.c:30)
==127995==    by 0x10D885: manage_and (25.manage_or_and.c:26)
==127995==    by 0x10D6F2: tree_execution (23.tree_execution.c:22)
==127995==    by 0x10A937: loop_routine (05.loop_routine.c:47)
==127995==    by 0x109E78: main (01.main.c:33)
==127995== 
LICENSE  Makefile  README.md  Simplified_shell_grammar.txt  _ci_cd  _tdd_utils  build  etq  headers  lazygit  lazygit.tar.gz  libs  manage_subshell.c  minishell  minishell_tester  readline.sup  src  two
==127928== Invalid read of size 8
==127928==    at 0x10A765: free_array (04.env_init_utils.c:68)
==127928==    by 0x111848: fork_and_execve (50.command_runner.c:36)
==127928==    by 0x111962: command_runner (50.command_runner.c:71)
==127928==    by 0x10E473: preprocessing_for_command_runner (29.manage_single_cmd.c:38)
==127928==    by 0x10E424: manage_single_command (29.manage_single_cmd.c:27)
==127928==    by 0x10D76D: tree_execution (23.tree_execution.c:30)
==127928==    by 0x10D885: manage_and (25.manage_or_and.c:26)
==127928==    by 0x10D6F2: tree_execution (23.tree_execution.c:22)
==127928==    by 0x10A937: loop_routine (05.loop_routine.c:47)
==127928==    by 0x109E78: main (01.main.c:33)
==127928==  Address 0x4b62d98 is 0 bytes after a block of size 392 alloc'd
==127928==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==127928==    by 0x112023: ft_calloc (ft_calloc.c:34)
==127928==    by 0x1119AA: convert_envs_to_array (51.command_runner_utils.c:25)
==127928==    by 0x111774: fork_and_execve (50.command_runner.c:20)
==127928==    by 0x111962: command_runner (50.command_runner.c:71)
==127928==    by 0x10E473: preprocessing_for_command_runner (29.manage_single_cmd.c:38)
==127928==    by 0x10E424: manage_single_command (29.manage_single_cmd.c:27)
==127928==    by 0x10D76D: tree_execution (23.tree_execution.c:30)
==127928==    by 0x10D885: manage_and (25.manage_or_and.c:26)
==127928==    by 0x10D6F2: tree_execution (23.tree_execution.c:22)
==127928==    by 0x10A937: loop_routine (05.loop_routine.c:47)
==127928==    by 0x109E78: main (01.main.c:33)
==127928== 
<<< Born Again (mini) SHell >>>$