NetBSD Problem Report #16140
Received: (qmail 28812 invoked from network); 31 Mar 2002 00:59:45 -0000
Message-Id: <Pine.SOL.4.33.0203310047470.15447-100000@draco.cus.cam.ac.uk>
Date: Sun, 31 Mar 2002 00:59:44 +0000 (GMT)
From: Ben Harris <bjh21@netbsd.org>
Sender: Ben Harris <bjh21@cus.cam.ac.uk>
To: <gnats-bugs@gnats.netbsd.org>
Subject: crunchgen calls mkstemp repeatedly with the same string
>Number: 16140
>Category: toolchain
>Synopsis: crunchgen calls mkstemp repeatedly with the same string
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: lukem
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Mar 31 01:00:01 +0000 2002
>Closed-Date: Sun Mar 31 08:03:10 +0000 2002
>Last-Modified: Wed May 13 13:21:39 +0000 2015
>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:
State-Changed-From-To: open->closed
State-Changed-By: lukem
State-Changed-When: Sun Mar 31 00:02:14 PST 2002
State-Changed-Why:
Problem solved; I moved tempfname[] into fillin_program_objs() and set it
before calling mkstemp(3). Bah, so much for consistency :)
Responsible-Changed-From-To: toolchain-manager->lukem
Responsible-Changed-By: lukem
Responsible-Changed-When: Sun Mar 31 00:02:14 PST 2002
Responsible-Changed-Why:
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.