summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/mktemp.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix a few bugs with the _gettemp() routine which implements mkstemp(),jhb2008-07-281-11/+26
| | | | | | | | | | | | | | | mkstemps(), and mkdtemp(). - Add proper range checking for the 'slen' parameter passed to mkstemps(). - Try all possible permutations of a template if a collision is encountered. Previously, once a single template character reached 'z', it would not wrap around to '0' and keep going until it encountered the original starting letter. In the edge case that the randomly generated starting name used all 'z' characters, only that single name would be tried before giving up. PR: standards/66531 Submitted by: Jim Luther Obtained from: Apple MFC after: 1 week
* Use arc4random_uniform(3) since modulo size is not power of 2ache2008-07-221-1/+1
|
* Per Regents of the University of Calfornia letter, remove advertisingimp2007-01-091-4/+0
| | | | | | clause. # If I've done so improperly on a file, please let me know.
* Eliminate 61 warnings emitted at WARNS=2 (leaving 53 to go).nectar2003-02-161-2/+2
| | | | | | | Only warnings that could be fixed without changing the generated object code and without restructuring the source code have been handled. Reviewed by: /sbin/md5
* Correct a check for NUL.robert2002-05-271-1/+1
| | | | Spotted by: bde
* - Move the loop conditional into the "for" header.robert2002-05-271-19/+17
| | | | | | | | - Remove redundant "? :" construct. style(9): - Place a space after return statements. - Compare pointers to NULL. - Do not use ! to compare a character to nul.
* Avoid wandering over the beginning of the actual bufferrobert2002-05-231-1/+1
| | | | | | | if the passed template string contains only 'X' characters. Submitted by: Mark Andrews <marka@isc.org> (patch modified) PR: 38402
* Fix the style of the SCM ID's.obrien2002-03-221-4/+2
| | | | I believe have made all of libc .c's as consistent as possible.
* Remove __P() usage.obrien2002-03-211-2/+2
|
* Remove 'register' keyword.obrien2002-03-211-2/+2
|
* Remove _THREAD_SAFE and make libc thread-safe by default bydeischen2001-01-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch
* Increase the size of the mktemp() filename space by dropping the PID fromkris2000-11-101-25/+17
| | | | | | | | | | | | | the encoding and using the character set [a-zA-Z0-9]. This gives a total of 62^6 = 56800235584 possible temporary filenames for the usual default invocation of 6 X's (compared to as few as 52 possibilities for the previous algorithm where up to 5 characters were wasted by the PID). Update some apparently bitrotten comments to reflect reality. Audited by: eivind, freebsd-audit Reviewed by: freebsd-current (a while ago) Originally submitted by: Peter Jeremy <Peter.Jeremy@alcatel.com.au>
* Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),jasone2000-01-271-1/+1
| | | | | | | | | | | | | | | | | just use _foo() <-- foo(). In the case of a libpthread that doesn't do call conversion (such as linuxthreads and our upcoming libpthread), this is adequate. In the case of libc_r, we still need three names, which are now _thread_sys_foo() <-- _foo() <-- foo(). Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(), nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo(). Remove all internal libc usage of: creat(), pause(), sleep(), system(), tcdrain(), wait(), and waitpid(). Make thread cancellation fully POSIX-compliant. Suggested by: deischen
* Add three-tier symbol naming in support of POSIX thread cancellationjasone2000-01-121-1/+1
| | | | | | points. For library functions, the pattern is __sleep() <-- _libc_sleep() <-- sleep(). The arrows represent weak aliases. For system calls, the pattern is _read() <-- _libc_read() <-- read().
* While comparing this with OpenBSD (ie: trying to figure out what mkstemps()peter1999-12-111-2/+2
| | | | | | | | is good for... :-)), I discovered that part of the change when mkstemps() was brought in was missed - it was missing the termination case to make sure it doesn't walk into the suffix. This isn't the same code OpenBSD has, I think this is a little better as we terminate the loop in a better spot.
* Add unsigned char cast to isdigitache1999-11-041-1/+1
|
* Remove UNSAFE_WARN ifdef for mktemp warning (never defined)ache1999-10-241-2/+0
| | | | Use _mktemp internally
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Add mkstemps from OpenBSD. This has been in my tree for months andimp1999-04-041-7/+24
| | | | | | hasn't caused any problems until the egcs import. This fix breaks the world build, but my very next commit will remove mkstemps from the egcs build.
* Revert last change. mkstemp() wasn't to blame, it's nvi. However,peter1998-10-201-21/+5
| | | | mkstemp() is not behaving as documented.
* Stop mk*temp() from being pathologically stupid in the face of a umask(0);peter1998-10-201-5/+21
| | | | | | | There are other ways to fix this than wrapping _gettemp(), but this was the most convenient. Discovered by: bde
* Fix a nasty flaw as a result of using the arc4random() pre-seeding ofpeter1998-04-141-2/+4
| | | | | | | | leading XXX's. It could wrap an uppercase character through chars like: [ \ ] ^ _ ` in between Z and a. The backslash and back tick might be particularly nasty in a shell script context. Also, since we've been using upper-case generated values for a while now, go with the flow and use them in the pathname search rotation.
* Fixed uninitialized pointer in previous commit. mktemp() was broken.bde1998-03-031-5/+6
| | | | | | I noticed cvs core dumps and uncleaned cvs temporary files in /tmp. Fixed ANSIisms.
* Many security improvements from OpenBSD:imp1998-02-131-23/+70
| | | | | | | | | | | implement mkdtemp improve man page for mk*temp use arc4random to seed extra XXX's randomly Optionally warn of unsafe mktemp uses From various commits by theo de raadt and Todd Miller. Obtained from: OpenBSD This should go into 2.2 after a testing period.
* Fix raceguido1997-04-071-2/+2
| | | | Obtained from: Keith Bostic
* Revert $FreeBSD$ to $Id$peter1997-02-221-1/+1
|
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Suggested by: Bruce Evans, Jeffrey Hsu, Gary Palmerjraynard1996-06-221-4/+9
| | | | | | | | | | | | | | | | | | | | | Added $Id$'s to files that were lacking them (gpalmer), made some cosmetic changes to conform to style guidelines (bde) and checked against NetBSD and Lite2 to remove unnecessary divergences (hsu, bde) One last code cleanup:- Removed spurious casts in fseek.c and stdio.c. Added missing function argument in fwalk.c. Added missing header include in flags.c and rget.c. Put in casts where int's were being passed as size_t's. Put in missing prototypes for static functions. Changed second args of __sflags() inflags.c and writehook() in vasprintf.c from char * to const char * to conform to prototypes. This directory now compiles with no warnings with -Wall under gcc-2.6.3 and with considerably less warnings than before with the ultra-pedantic script I used for testing. (Most of the remaining ones are due to const poisoning).
* Code cleanup:-jraynard1996-06-121-5/+4
| | | | | | The usual stuff, adding missing function prototypes, argument types, return values, etc. In mktemp.c, convert pid from u_int to pid_t, and get rid of "extern int errno".
* Minor cleanup, #include's and unused vars.phk1995-10-221-0/+1
| | | | Added compile-time warning to an old funky function.
* BSD 4.4 Lite Lib Sourcesrgrimes1994-05-271-0/+126
OpenPOWER on IntegriCloud