libxslt/CVE-2015-9019.patch

43 lines
782 B
Diff
Raw Permalink Normal View History

2022-11-05 19:34:13 +08:00
diff --git a/libexslt/math.c b/libexslt/math.c
index 17138b2..c9f9e5a 100644
--- a/libexslt/math.c
+++ b/libexslt/math.c
@@ -11,6 +11,13 @@
#include <math.h>
2019-09-30 10:59:48 -04:00
#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <fcntl.h>
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
#include "exslt.h"
2022-11-05 19:34:13 +08:00
@@ -460,6 +467,20 @@ static double
2019-09-30 10:59:48 -04:00
exsltMathRandom (void) {
double ret;
int num;
+ long seed;
+ static int randinit = 0;
+
+ if (!randinit) {
+ int fd = open("/dev/urandom",O_RDONLY);
+
+ seed = time(NULL); /* just in case /dev/urandom is not there */
+ if (fd == -1) {
+ read (fd, &seed, sizeof(seed));
+ close (fd);
+ }
+ srand(seed);
+ randinit = 1;
+ }
num = rand();
ret = (double)num / (double)RAND_MAX;
2022-11-05 19:34:13 +08:00
--
2.27.0