Defect Report #336

Previous Defect Report < - > Next Defect Report


Submitter: Stoughton (US)
Submission Date: 2007-02-01
Source: The Austin Group
Reference Document:  2004:XBD ERN 83
Version: 1.3
Date: 2007-10-10
Subject: TMP_MAX

Summary: What does TMP_MAX actually indicate?

This is a potential defect forwarded from the Austin Group.

There is a conflict between POSIX.1 and C99 over the description of TMP_MAX. POSIX.1 describes it as:

"Minimum number of unique filenames generated by tmpnam(). Maximum number of times an application can call tmpnam() reliably."
C99 (17.19.1, para 3) says it is
"the maximum number of unique file names that can be generated by the tmpnam function".

That is to say, for POSIX, it is not an error for tmpnam() to not fail when called TMP_MAX+1 times, while it is implied by the C standard that it must fail.

POSIX goes on to state:

"If tmpnam()is called more than {TMP_MAX} times, the behavior is implementation-defined."

It should also be noted that the tmpfile function (7.19.4.3) also uses TMP_MAX, but as a minimum maximum:

"It should be possible to open at least TMP_MAX temporary files during the lifetime of the program (this limit may be shared with tmpnam)"

Suggested Technical Corrigendum

Change 7.19.1 para 3 from:

the maximum number of unique file names that can be generated by the tmpnam function".

to:

the minimum number of unique file names that can be generated by the tmpnam function".

Also, at 7.19.4.4 p2, change

"The function is potentially capable of generating TMP_MAX different strings, but any or all of them may already be in use by existing files and thus not be suitable return values."
to
"The function is potentially capable of generating at least TMP_MAX different strings, but any or all of them may already be in use by existing files and thus not be suitable return values. It is implementation defined if tmpnam can generate more than TMP_MAX different strings."

Committee Discussion (for history only)

Proposed Technical Corrigendum

Change 7.19.1 para 3 from:

the maximum number of unique file names that can be generated by the tmpnam function".

to:

the minimum number of unique file names that can be generated by the tmpnam function".

Also, at 7.19.4.4 p2, change

"The function is potentially capable of generating TMP_MAX different strings, but any or all of them may already be in use by existing files and thus not be suitable return values."
to
"The function is potentially capable of generating at least TMP_MAX different strings, but any or all of them may already be in use by existing files and thus not be suitable return values."
Previous Defect Report < - > Next Defect Report