From: Richard M. Stallman Date: Sat, 2 May 1998 06:00:42 +0000 (+0000) Subject: (Fmake_temp_name): Improve randomness of generated file names. X-Git-Tag: emacs-20.3~1177 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8a7777fc1a5625685fab4ddbc5f6031ab591efb3;p=emacs.git (Fmake_temp_name): Improve randomness of generated file names. --- diff --git a/src/fileio.c b/src/fileio.c index b1ad711555d..16350504669 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -862,12 +862,17 @@ PREFIX should be an absolute file name.") while (1) { struct stat ignored; - unsigned num = make_temp_name_count++; + unsigned num = make_temp_name_count; p[0] = make_temp_name_tbl[num & 63], num >>= 6; p[1] = make_temp_name_tbl[num & 63], num >>= 6; p[2] = make_temp_name_tbl[num & 63], num >>= 6; + /* Poor man's congruential RN generator. Replace with + ++make_temp_name_count for debugging. */ + make_temp_name_count += 25229; + make_temp_name_count %= 225307; + if (stat (data, &ignored) < 0) { /* We want to return only if errno is ENOENT. */ @@ -878,9 +883,9 @@ PREFIX should be an absolute file name.") can do. The alternatives are to return nil, which is as bad as (and in many cases worse than) throwing the error, or to ignore the error, which will likely result - in looping through 262144 stat's, which is not only - SLOW, but also useless since it will fallback to the - errow below, anyway. */ + in looping through 225307 stat's, which is not only + dog-slow, but also useless since it will fallback to + the errow below, anyway. */ report_file_error ("Cannot create temporary name for prefix `%s'", Fcons (prefix, Qnil)); /* not reached */