glibc/glibc-rh878913.patch
Siddhesh Poyarekar 99d5069200 Bug fixes (878913, 880666)
- Ensure that hashtable size is greater than 3 (#878913).
  - fwrite returns 0 on EOF (#880666).
2012-11-27 21:31:22 +05:30

28 lines
754 B
Diff

diff --git a/nss/makedb.c b/nss/makedb.c
index 8d7d027..fdcf4c6 100644
--- a/nss/makedb.c
+++ b/nss/makedb.c
@@ -591,10 +591,12 @@ copy_valstr (const void *nodep, const VISIT which, const int depth)
}
+/* Check if a number is prime. We check only odd numbers greater than 10.
+ Enter even numbers and watch the function fail in mysterious ways. Odd
+ numbers less than 10 return false even if they are prime. */
static int
is_prime (size_t candidate)
{
- /* No even number and none less than 10 will be passed here. */
size_t divn = 3;
size_t sq = divn * divn;
@@ -605,7 +607,7 @@ is_prime (size_t candidate)
++divn;
}
- return candidate % divn != 0;
+ return (candidate >= divn && candidate % divn != 0);
}