[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

r2108 - in glibc-package/trunk/debian: . patches patches/any



Author: aurel32
Date: 2007-04-21 21:29:02 +0000 (Sat, 21 Apr 2007)
New Revision: 2108

Added:
   glibc-package/trunk/debian/patches/any/submitted-strfry.diff
Modified:
   glibc-package/trunk/debian/changelog
   glibc-package/trunk/debian/patches/series
Log:
  * debian/patches/any/submitted-strfry.diff: new patch (fix strfry()
    distribution) by Steinar H. Gunderson.  Closes: #341903.



Modified: glibc-package/trunk/debian/changelog
===================================================================
--- glibc-package/trunk/debian/changelog	2007-04-21 21:07:09 UTC (rev 2107)
+++ glibc-package/trunk/debian/changelog	2007-04-21 21:29:02 UTC (rev 2108)
@@ -19,6 +19,8 @@
     realpath() in /usr/include/stdlib) from CVS.  Closes: #239427.
   * debian/local/manpages/iconv.1: mention that -t is optional.  Closes: 
     #354292.
+  * debian/patches/any/submitted-strfry.diff: new patch (fix strfry()
+    distribution) by Steinar H. Gunderson.  Closes: #341903.
 
  -- Aurelien Jarno <aurel32@debian.org>  Sat, 21 Apr 2007 21:33:04 +0200
 

Added: glibc-package/trunk/debian/patches/any/submitted-strfry.diff
===================================================================
--- glibc-package/trunk/debian/patches/any/submitted-strfry.diff	2007-04-21 21:07:09 UTC (rev 2107)
+++ glibc-package/trunk/debian/patches/any/submitted-strfry.diff	2007-04-21 21:29:02 UTC (rev 2108)
@@ -0,0 +1,29 @@
+Turn strfry() into a proper Fisher-Yates shuffle. This gives us exactly
+n! paths for a string with N characters, and since there are n! possible
+permutations, we get a one-to-one mapping, and all possibilities are 
+equally likely.
+
+--- string/strfry.c	2007-04-21 23:12:47.000000000 +0200
++++ string/strfry.c	2007-04-21 23:22:46.000000000 +0200
+@@ -38,17 +38,17 @@
+     }
+ 
+   len = strlen (string);
+-  for (i = 0; i < len; ++i)
++  for (i = 0; i < len - 1; ++i)
+     {
+       int32_t j;
+       char c;
+ 
+       __random_r (&rdata, &j);
+-      j %= len;
++      j %= (len - i);
+ 
+       c = string[i];
+-      string[i] = string[j];
+-      string[j] = c;
++      string[i] = string[j + i];
++      string[j + i] = c;
+     }
+ 
+   return string;

Modified: glibc-package/trunk/debian/patches/series
===================================================================
--- glibc-package/trunk/debian/patches/series	2007-04-21 21:07:09 UTC (rev 2107)
+++ glibc-package/trunk/debian/patches/series	2007-04-21 21:29:02 UTC (rev 2108)
@@ -141,5 +141,6 @@
 any/submitted-clock-settime.diff -p0
 any/submitted-date-and-unknown-tz.diff -p0
 any/submitted-gethostbyname_r.diff -p0
+any/submitted-strfry.diff -p0
 any/submitted-unistd_XOPEN_VERSION.diff
 any/cvs-glob-c.diff



Reply to: