Bug 915

Summary: [PATCH] Only copy basic Windows environment
Product: Portable OpenSSH Reporter: Corinna Vinschen <vinschen>
Component: sshdAssignee: OpenSSH Bugzilla mailing list <openssh-bugs>
Status: CLOSED FIXED    
Severity: security    
Priority: P2    
Version: -current   
Hardware: ix86   
OS: Cygwin on NT/2k/Win7-11   
Attachments:
Description Flags
The patch copies only the basic Windows environment over to child processes
dtucker: ok+
Modified patch with Darren's suggestions none

Description Corinna Vinschen 2004-08-18 17:38:24 AEST
So far, the whole environment is copied over to child processes
started from sshd when running under Cygwin.  The attached patch
restricts this to the basic environment created for all processes.
Comment 1 Corinna Vinschen 2004-08-18 17:39:51 AEST
Created attachment 698 [details]
The patch copies only the basic Windows environment over to child processes
Comment 2 Darren Tucker 2004-08-28 23:11:45 AEST
Comment on attachment 698 [details]
The patch copies only the basic Windows environment over to child processes

Looks OK to me.  A few minor comments:
[...]
>+	p[idx] = NULL;
>+	for (e = environ; *e; ++e) {

style guide says to explicitly test against NULL, ie "*e != NULL"

>+		for (i = 0; i < WENV_SIZ; ++i) {
>+			if (!strncmp(*e, wenv_arr[i].name,
>+				     wenv_arr[i].namelen)) {
>+				p[idx] = *e;
>+				p[++idx] = NULL;

You could make that "p[idx++] = *e", move "p[idx] = NULL" from above the loop
to below and delete "p[++idx] = NULL" from the loop.

It would be nice if the array didn't need to be structs but that would mean a
bit of run-time overhead and I don't think it would be any clearer anyway...
Comment 3 Corinna Vinschen 2004-08-29 00:59:59 AEST
Created attachment 706 [details]
Modified patch with Darren's suggestions
Comment 4 Darren Tucker 2004-08-30 20:44:46 AEST
Patch #706 applied, thanks.