Subject: lib/31383: Documentative omission in mktemp.3
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <tonnerre@thundrix.ch>
List: netbsd-bugs
Date: 09/24/2005 00:04:00
>Number: 31383
>Category: lib
>Synopsis: Documentative omission in mktemp.3
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: doc-bug
>Submitter-Id: net
>Arrival-Date: Sat Sep 24 00:04:00 +0000 2005
>Originator: Tonnerre Lombard
>Release: 3.99.9
>Organization:
/chaos/control
>Environment:
(doesn't matter)
>Description:
There is an implementation detail about mktemp() and gcc which causes a segmentation fault if one uses mktemp() in the seemingly most obvious way. The problem is created by the two facts that
1. mktemp() takes a string as an argument, but it actually writes to that string
2. gcc puts static strings into the readonly section
It's not properly documented yet that mktemp("/tmp/blubb-XXXXXX"); is going to cause a segfault for attempting to write to readonly memory. While this may be obvious to us, there have been some people who considered this a bug.
The solution, I think, is to document this behavior properly.
>How-To-Repeat:
int
main(void)
{
int fd = mkstemp("/tmp/blubb-XXXXXX");
close(fd);
exit(0);
}
>Fix:
http://users.thundrix.ch/~tonnerre/system/netbsd/mktemp-doc-fix.diff , maybe with properly changed wording or something