4 ms·
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 behaviou
by dwattttt 1y ago
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.
- 1718627440 1y agoNo it always leaks, regardless if your program now correctly invalidates all derived pointers upon calling setenv.
- ori_b 1y agoThe 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.