Bug 915 - [PATCH] Only copy basic Windows environment
Summary: [PATCH] Only copy basic Windows environment
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: -current
Hardware: ix86 Cygwin on NT/2k/Win7-11
: P2 security
Assignee: OpenSSH Bugzilla mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-18 17:38 AEST by Corinna Vinschen
Modified: 2004-09-11 13:18 AEST (History)
0 users

See Also:


Attachments
The patch copies only the basic Windows environment over to child processes (3.31 KB, patch)
2004-08-18 17:39 AEST, Corinna Vinschen
dtucker: ok+
Details | Diff
Modified patch with Darren's suggestions (3.28 KB, patch)
2004-08-29 00:59 AEST, Corinna Vinschen
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.