mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Remove mktemp(3).
This commit is contained in:
parent
3db8ef705e
commit
25482f875e
4 changed files with 9 additions and 42 deletions
|
@ -145,6 +145,15 @@ F_SETLKW) do and should be avoided for the same reasons (see above).
|
|||
Use the flock (not to be confused with lockf) call instead as it works at a file
|
||||
descriptor level.
|
||||
|
||||
mktemp
|
||||
------
|
||||
|
||||
mktemp(3) (not the mktemp(1) utility) creates a unique path name, but creates no
|
||||
file, and thus offers no guarantee that is unique with respect to other threads
|
||||
and system processes. The function is racy and dangerous.
|
||||
|
||||
Use mkstemp(3) (or for directories mkdtemp(3)) instead.
|
||||
|
||||
PATH_MAX
|
||||
--------
|
||||
|
||||
|
|
|
@ -455,7 +455,6 @@ stdlib/mkostemp.o \
|
|||
stdlib/mkostemps.o \
|
||||
stdlib/mkstemp.o \
|
||||
stdlib/mkstemps.o \
|
||||
stdlib/mktemp.o \
|
||||
stdlib/on_exit.o \
|
||||
stdlib/rand.o \
|
||||
stdlib/realpath.o \
|
||||
|
|
|
@ -110,10 +110,6 @@ int mkostemp(char*, int);
|
|||
int mkostemps(char*, int, int);
|
||||
int mkstemp(char*);
|
||||
int mkstemps(char*, int);
|
||||
#if !defined(__is_sortix_libc) /* not a warning inside libc */
|
||||
__attribute__((__warning__("mktemp() is racy, use mkstemp()")))
|
||||
#endif
|
||||
char* mktemp(char* templ);
|
||||
int on_exit(void (*function)(int, void*), void* arg);
|
||||
void qsort(void*, size_t, size_t, int (*)(const void*, const void*));
|
||||
void qsort_r(void*, size_t, size_t, int (*)(const void*, const void*, void*), void*);
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
||||
|
||||
This file is part of the Sortix C Library.
|
||||
|
||||
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
stdlib/mktemp.cpp
|
||||
Make a unique temporary filename.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// TODO: This is a hacky implementation of a stupid function.
|
||||
extern "C" char* mktemp(char* templ)
|
||||
{
|
||||
size_t templlen = strlen(templ);
|
||||
for ( size_t i = templlen-6UL; i < templlen; i++ )
|
||||
{
|
||||
templ[i] = '0' + rand() % 10;
|
||||
}
|
||||
return templ;
|
||||
}
|
Loading…
Reference in a new issue