Laurence Tratt <lau...@tratt.net> wrote: > On Sun, Feb 02, 2020 at 04:20:13PM -0700, Theo de Raadt wrote: > > Hello Theo, > > > What is the difference between storage and contents > > You can't free() the backing memory *and* (according to GNU's man page, at > least) you can't safely change the string contents either on some OSs. I've > tried something slightly lengthier in the patch below. > > > (actually contents could change. As long as there is always a terminating > > NUL, for the purpose of traversal. But that's not something someone should > > code to) > > > > You still didn't say how you ran into this. > > While writing a daemon in Rust, I discovered that, AFAICT, one doesn't have > sensible access to __progname
Pretty ignorant of them. > and has to figure out the executable name > dynamically (AFAICT), That is impossible on many systems, or possible ... but can fail to deliver a name and then what? > so it ends up in malloc'd storage. yes so, why was it being freed? > When I passed that to openlog, and later called syslog, well, I was > confused. I then distilled the example down to C. The Debian & GNU man > pages suggest that I'm not the first person to try doing this. That would only be true if you've looked at the history of how that text ended up in their pages, as it is, I think either way overspecifies it, I think openlog() could plausibly be coded to cache a copy of the whole string. The standard may have left this open-ended intentionally. Is there a historian watching this thread?