Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It would be a problem, except that the behaviour you're moving away from is a stale pointer. So surely any application that'd be leaking under that new behaviour would be crashing today.


The same advice applies to a correct program regardless of the implementation: using setenv is a bug. Only use getenv.

Getenv in a program without setenv is fine in both implementations. Setenv is unusable with all conforming implementations.

To pass environments to children, use execve.

The Linux behavior allows a careful single threaded program to use setenv correctly. The BSD/Solaris behavior makes all usage incorrect, but the incorrectness comes in the form of a memory leak, which is preferable to a security issue, usually.

There's no correct, portable use of setenv. If you call it, it's a bug.


No it always leaks, regardless if your program now correctly invalidates all derived pointers upon calling setenv.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: