summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2016-01-15 16:01:35 +0100
committerWerner Koch <wk@gnupg.org>2016-01-15 16:01:35 +0100
commit6303b0e83856ee89374b447e710f0ab2af61caec (patch)
treed96ade40ab4d748a37948951d7729d262335085e
parent5a78e7f15e0dd96a8bf64e2bb142880bf8ea6965 (diff)
downloadlibgcrypt-6303b0e83856ee89374b447e710f0ab2af61caec.tar.gz
random: Fix possible AIX problem with sysconf in rndunix.
* random/rndunix.c [HAVE_STDINT_H]: Include stdint.h. (start_gatherer): Detect misbehaving sysconf. -- See GnuPG-bug-id: 1778 for the reason of this patch. There is no concrete bug report but this change should not harm. Signed-off-by: Werner Koch <wk@gnupg.org>
-rw-r--r--random/rndunix.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/random/rndunix.c b/random/rndunix.c
index 315906b0..2e132985 100644
--- a/random/rndunix.c
+++ b/random/rndunix.c
@@ -86,6 +86,9 @@
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
#include <string.h>
/* OS-specific includes */
@@ -726,12 +729,18 @@ start_gatherer( int pipefd )
{ int nmax, n1, n2, i;
#ifdef _SC_OPEN_MAX
if( (nmax=sysconf( _SC_OPEN_MAX )) < 0 ) {
-#ifdef _POSIX_OPEN_MAX
+# ifdef _POSIX_OPEN_MAX
nmax = _POSIX_OPEN_MAX;
-#else
+# else
nmax = 20; /* assume a reasonable value */
-#endif
+# endif
}
+ /* AIX returns INT32_MAX instead of a proper value. We assume that
+ * this is always an error and use a reasonable value. */
+# ifdef INT32_MAX
+ if (nmax == INT32_MAX)
+ nmax = 20;
+# endif
#else /*!_SC_OPEN_MAX*/
nmax = 20; /* assume a reasonable value */
#endif /*!_SC_OPEN_MAX*/