As mentioned here the book Expert C Programming contains the claim that there was a bug in SunOS 4.0.3's version of lpr
, (a printing program) caused by a custom mktemp
function overriding the library function of the same name when called by getwd
.
The example code describing the problem was:
my_source.c
mktemp() { ... }
main() {
mktemp();
getwd();
}
libc
mktemp(){ ... }
getwd(){ ...; mktemp(); ... }
My assumption is that getwd
is meant to get the current working directory, and mktemp
is meant to make a temporary file name, like, if not identical to the linux functions with the same names.
My question is, why would getwd
call mktemp
? That is, why would the function to get the working directory, need to make a temporary file name?
The only possible reason I can think of is that sometimes you end up with a process that doesn't have a real working directory, so a temporary one is returned. But that doesn't seem likely to me. Also, if that was the reason, why would processes end up without working directories often enough that it was a noticeable problem?
getwd()
say? Did you try to find source code (Solaris as a branch was at times open source)? Additionally BSD and Linux implementations might also give some hint.