19 Commits

Author SHA1 Message Date
Szabolcs Nagy
571744447c include cleanups: remove unused headers and add feature test macros 2013-12-12 05:09:18 +00:00
Rich Felker
ff4d6020d1 fix typo in comment in __randname 2013-09-04 10:23:42 -04:00
Rich Felker
38f44d6923 fix (deprecated) mktemp logic and update it to match other temp functions
the access function cannot be used to check for existence, because it
operates using real uid/gid rather than effective to determine
accessibility; this matters for the non-final path components.
instead, use stat. failure of stat is success if only the final
component is missing (ENOENT) and otherwise is failure.
2013-08-02 01:06:53 -04:00
Rich Felker
9a97d103fb remove (no longer useful) namespace-protected __mktemp symbol 2013-08-02 00:52:50 -04:00
Rich Felker
c4685ae429 make mkdtemp and mkstemp family leave template unchanged on fail
also refactor mkdtemp based on new shared temp code, removing
dependency on the deprecated mktemp, whose behavior made this logic
more difficult.
2013-08-02 00:48:48 -04:00
Rich Felker
8872e4e481 use memcmp instead of str[n]cmp for temp function XXXXXX checking 2013-02-20 23:01:22 -05:00
Rich Felker
8d2f8064aa fix error cases in mkostemps core
1. wrong return value and missing errno for negative suffix len
2. failure to catch suffix len > strlen
3. remove unwanted clearing of input string in invalid case
2013-02-20 22:58:46 -05:00
Rich Felker
3b00675bf5 remove leftover unused variable in mktemp after refactoring 2013-02-20 22:56:53 -05:00
Rich Felker
2cc63358cd add mkostemp, mkstemps, and mkostemps functions and reorganize temp internals
based on patch contributed by Anthony G. Basile (blueness)

some issues remain with the filename generation algorithm and other
small bugs, but this patch has been sitting around long enough that I
feel it's best to get it committed and then work out any remaining
issues.
2013-02-20 22:43:23 -05:00
Rich Felker
aed707f679 remove ugly prng from mk*temp and just re-poll time on retry 2011-07-28 22:03:54 -04:00
Rich Felker
bbdcc403ca eliminate mk*temp dependency on snprintf
this helps some tiny programs be even more tiny, and barly increases
code size even if both are used.
2011-07-28 21:48:53 -04:00
Rich Felker
3825847243 another return value fix for mktemp... 2011-06-12 10:25:29 -04:00
Rich Felker
69ecbd0f31 make mktemp match the historic behavior, and update functions that use it
the historic mktemp is supposed to blank the template string on
failure, rather than returning 0. just zero the first character so
that mkstemp and mkdtemp can still retry with O(1) space requirement.
2011-02-19 09:40:07 -05:00
Rich Felker
2e6239dd06 fix major bug created from copying mkdtemp logic 2011-02-19 09:34:28 -05:00
Rich Felker
446b4207cc major improvements to temp file name generator
use current time in nanoseconds and some potentially-random (if aslr
is enabled) pointer values for the initial tempfile name generation,
and step via a cheap linear prng on collisions. limit the number of
retry attempts to prevent denial of service attacks even if an
attacker can guess the filenames.
2011-02-18 17:04:56 -05:00
Rich Felker
3e9e30166f reformat mkstemp like mkdtemp
this is cleaner and makes it easy to impose a limit on the number of
retries later if it seems desirable to do so.
2011-02-18 16:32:33 -05:00
Rich Felker
5377715ce0 ensure standard functions mk[sd]temp don't depend on removed function mktemp 2011-02-14 19:18:06 -05:00
Rich Felker
80695b1d1e begin namespace-cleanup of standard C headers 2011-02-14 05:10:10 -05:00
Rich Felker
0b44a0315b initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00