Subject: toolchain/16140: crunchgen calls mkstemp repeatedly with the same string
To: None <gnats-bugs@gnats.netbsd.org>
From: Ben Harris <bjh21@netbsd.org>
List: netbsd-bugs
Date: 03/31/2002 00:59:44
>Number:         16140
>Category:       toolchain
>Synopsis:       crunchgen calls mkstemp repeatedly with the same string
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 30 17:00:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Ben Harris
>Release:        2002-03-30
>Organization:
>Environment:
Debian GNU/Linux 2.2

>Description:
In crunchgen/crunchgen.c, there's a global variable called tempfname.
It's initialised in main() to contain "/tmp/%sXXXXXX", with %s replaced by
  an appropriate string.
main() calls gen_outputs(), which calls fillin_program() several times.
Each call to fillin_program() causes a call to fillin_program_objs(),
  which calls mkstemp(), passing tempfname as an argument.
mkstemp() replaces the string it's passed with the new temporary file
  name, so on the second call, it gets back its own output, which probably
  doesn't have any Xs in it, and hence causes glibc's mkstemp() to fail
  with EINVAL.

>How-To-Repeat:
Build crunchgen on Linux, after working around PR 13169, and get a message
saying something like this when running it:

/tmp/ramdiskbinxyz123: Invalid argument

>Fix:
Moving the snprintf() call that initialises tempfname from the end of
main() to the start of fillin_program_objs() seems to help, but I'm not
sure it's right, since I don't really understand crunchgen.




>Release-Note:
>Audit-Trail:
>Unformatted: