Re: Secure C library - fopentmp_s (a usable secure create and open named temporary file)
- From: Roland Illig <roland.illig@xxxxxx>
- Date: Tue, 06 Sep 2005 09:42:27 +0200
Jonathan Leffler wrote:
I was faintly hoping to avoid having to do that. I fully accept that as proposed, fopentmp_s() does not permit you to specify:
* Created file access permissions.
* A template (that is, directory location) for the created file.
* The file mode (I mentioned "wb+" because the tmpfile_s() does).
I would like to be able to specify all three.
errno_t fopentmp_s(FILE **stream, const char *mode, char *fname, rsize_t fname_size);
[...]
fname shall contain the (possibly empty) initial portion of the filename to be generated. The filename is then generated by filling the remaining {bytes/characters?} of fname[].
[...]
Although this specification would allow many different implementations, the drawback is that it assumes that the initial portion of a filename has some useful interpretation, like directory names in POSIX and Windows. An implementation where the order of directories were reversed, like "file|dir|drive", would not benefit from this specification.
Portable applications should then always leave the fname empty to allow the implementation to choose freely from the set of available filenames.
FILE *f; char fname[80];
fname[0] = '\0'; /* allow arbitrary file names */
if (fopentmp_s(&f, "a+", fname, sizeof(fname)) == 0) {
...
}Another possibility would be to add a template parameter which specifies (in an implementation-defined manner) how the filename is to be constructed. This could be the initial portion of the filename on POSIX and Windows, and maybe the final portion on my imagined implementation with the reversed pathnames.
Roland .
- Follow-Ups:
- References:
- Secure C library
- From: jacob navia
- Re: Secure C library
- From: P.J. Plauger
- Re: Secure C library
- From: Robert Gamble
- Re: Secure C library
- From: P.J. Plauger
- Re: Secure C library - fopentmp_s (a usable secure create and open named temporary file)
- From: Jonathan Leffler
- Re: Secure C library - fopentmp_s (a usable secure create and open named temporary file)
- From: Antoine Leca
- Re: Secure C library - fopentmp_s (a usable secure create and open named temporary file)
- From: Jonathan Leffler
- Secure C library
- Prev by Date: Re: Secure C library - fopentmp_s (a usable secure create and open named temporary file)
- Next by Date: Re: Secure C library - fopentmp_s (a usable secure create and open named temporary file)
- Previous by thread: Re: Secure C library - fopentmp_s (a usable secure create and open named temporary file)
- Next by thread: Re: Secure C library - fopentmp_s (a usable secure create and open named temporary file)
- Index(es):
Relevant Pages
|