News for hackers. Stuff that matters.
Re:Getaddrinfo() on glibc calls getenv(), oh boy by asveikau on Tuesday October 17, 2023 @05:36PM (#37921934)
Modifying the buffer returned by getenv() seems like a terrible way to write back a value, because you could only replace it with a string with equal or shorter length. One of the problems setenv() solves is allocation.

It's important to note the difference between reentrant and thread safe. The most obvious implementation of getenv(), which would just loop through environ(7) and do a bunch of strncmp, can safely be re-entered, in that you could interrupt it and call it again and it would produce no ill effect. It just can't be overlapped with writes.

There are no comments on this comment yet.