[LEDE-DEV,procd,01/17] utrace: Fix environment initialization

Message ID 20170912111250.31576-4-sojkam1@fel.cvut.cz
State Accepted
Headers show
Series
  • [LEDE-DEV,procd,01/17] utrace: Fix environment initialization
Related show

Commit Message

Michal Sojka Sept. 12, 2017, 11:12 a.m.
We want to copy the existing environment instead of the new one to
itself. Other bugs in this code are fixed in the next commit.

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
---
 trace/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John Crispin Sept. 21, 2017, 8:06 p.m. | #1
Hi Michal.

sorry for the delay, i am halfway through reviewing your patches. thanks 
for sending them.

     John


On 12/09/17 13:12, Michal Sojka wrote:
> We want to copy the existing environment instead of the new one to
> itself. Other bugs in this code are fixed in the next commit.
>
> Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
> ---
>   trace/trace.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/trace/trace.c b/trace/trace.c
> index fdffaba..04bf7a5 100644
> --- a/trace/trace.c
> +++ b/trace/trace.c
> @@ -186,7 +186,7 @@ int main(int argc, char **argv, char **envp)
>   			;
>   
>   		_envp = calloc(envc, sizeof(char *));
> -		memcpy(&_envp[1], _envp, envc * sizeof(char *));
> +		memcpy(&_envp[1], envp, envc * sizeof(char *));
>   		*_envp = preload;
>   
>   		ret = execve(_argv[0], _argv, _envp);
Michal Sojka Sept. 21, 2017, 8:09 p.m. | #2
On Thu, Sep 21 2017, John Crispin wrote:
> Hi Michal.
>
> sorry for the delay, i am halfway through reviewing your patches. thanks 
> for sending them.

No problem, thanks for reviewing :)

-Michal

Patch

diff --git a/trace/trace.c b/trace/trace.c
index fdffaba..04bf7a5 100644
--- a/trace/trace.c
+++ b/trace/trace.c
@@ -186,7 +186,7 @@  int main(int argc, char **argv, char **envp)
 			;
 
 		_envp = calloc(envc, sizeof(char *));
-		memcpy(&_envp[1], _envp, envc * sizeof(char *));
+		memcpy(&_envp[1], envp, envc * sizeof(char *));
 		*_envp = preload;
 
 		ret = execve(_argv[0], _argv, _envp);