aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-11-27 03:47:06 +0000
committerUlrich Drepper <drepper@redhat.com>2001-11-27 03:47:06 +0000
commit8e9b2075ba1d6ce2ab82c2eb2547e2c2ef3ecca8 (patch)
treede7fba86c989c6f7df1d6d7bac078813d0855fa3 /sysdeps/posix
parentf4efd06825ba5fec62662be611d94335eff4f8f7 (diff)
downloadglibc-8e9b2075ba1d6ce2ab82c2eb2547e2c2ef3ecca8.tar
glibc-8e9b2075ba1d6ce2ab82c2eb2547e2c2ef3ecca8.tar.gz
glibc-8e9b2075ba1d6ce2ab82c2eb2547e2c2ef3ecca8.tar.bz2
glibc-8e9b2075ba1d6ce2ab82c2eb2547e2c2ef3ecca8.zip
Update.
2001-11-21 Bruno Haible <bruno@clisp.org> * charmaps/ISO-8859-16: Swap 0xa5 and 0xab entries.
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/tempname.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
index 9c6bc8f5a6..0d4bbc418a 100644
--- a/sysdeps/posix/tempname.c
+++ b/sysdeps/posix/tempname.c
@@ -231,10 +231,23 @@ __gen_tempname (char *tmpl, int kind)
char *XXXXXX;
static uint64_t value;
uint64_t random_time_bits;
- int count, fd = -1;
+ unsigned int count;
+ int fd = -1;
int save_errno = errno;
struct_stat64 st;
+ /* A lower bound on the number of temporary files to attempt to
+ generate. The maximum total number of temporary file names that
+ can exist for a given template is 62**6. It should never be
+ necessary to try all these combinations. Instead if a reasonable
+ number of names is tried (we define reasonable as 62**3) fail to
+ give the system administrator the chance to remove the problems. */
+ unsigned int attempts_min = 62 * 62 * 62;
+
+ /* The number of times to attempt to generate a temporary file. To
+ conform to POSIX, this must be no smaller than TMP_MAX. */
+ unsigned int attempts = attempts_min < TMP_MAX ? TMP_MAX : attempts_min;
+
len = strlen (tmpl);
if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))
{
@@ -261,7 +274,7 @@ __gen_tempname (char *tmpl, int kind)
#endif
value += random_time_bits ^ __getpid ();
- for (count = 0; count < TMP_MAX; value += 7777, ++count)
+ for (count = 0; count < attempts; value += 7777, ++count)
{
uint64_t v = value;