environ problem

Mark Weaver mark@npsl.co.uk
Mon Jul 10 08:11:00 GMT 2000


I am currently in the process of a sendmail port to NT, based on cygwin.  I
have discovered that sendmail internally modifies environ, and then uses
putenv to modify the resulting environment (sample code that I abstracted
attached below) - doing this causes cygwin compiled programs to crash (due
in fact to an overwrite of the import address table).  (The crash might not
be immediate; a number of putenv calls are sometimes required for the
appropriate chunk of memory to be overwritten).

Before I `fix' this behaviour, does POSIX allow for modifying environ?  And
even if it doesn't, then is the practice widespread enough for it to be
worth supporting?  (i.e. should I fix cygwin or sendmail!)

Thanks,

Mark

code snippet:

int main()
{
	char *emptyenviron[1];
	char** ExternalEnviron;

	emptyenviron[0] = NULL;
	ExternalEnviron = environ;
	environ = emptyenviron;

	putenv("AGENT=sendmail"); // access violation here
	return 1;
}


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list