summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/lynx
diff options
context:
space:
mode:
authorRobert Nagy <robert@cvs.openbsd.org>2005-11-27 21:45:21 +0000
committerRobert Nagy <robert@cvs.openbsd.org>2005-11-27 21:45:21 +0000
commitb3bc7c4e0de0f2b82ba5379e8f5a6a54549d565f (patch)
tree8353c6429564ad8bdb7cd0fef7faf0ab1b3c1954 /gnu/usr.bin/lynx
parentb2fafc5cbfb504a474834fb4200f4bce2e91a1c5 (diff)
make lynx(1) to use arc4random(4) instead of other random functions;
avoid a segfault by checking the value of TAB TO; from Alexey Dobriyan <adobriyan@gmail.com>; pushed by deraadt@
Diffstat (limited to 'gnu/usr.bin/lynx')
-rw-r--r--gnu/usr.bin/lynx/WWW/Library/Implementation/HTTP.c2
-rw-r--r--gnu/usr.bin/lynx/aclocal.m48
-rw-r--r--gnu/usr.bin/lynx/configure8
-rw-r--r--gnu/usr.bin/lynx/src/HTML.c3
-rw-r--r--gnu/usr.bin/lynx/src/LYUtils.c2
5 files changed, 18 insertions, 5 deletions
diff --git a/gnu/usr.bin/lynx/WWW/Library/Implementation/HTTP.c b/gnu/usr.bin/lynx/WWW/Library/Implementation/HTTP.c
index 93fe4bb489e..fd3e11f76ac 100644
--- a/gnu/usr.bin/lynx/WWW/Library/Implementation/HTTP.c
+++ b/gnu/usr.bin/lynx/WWW/Library/Implementation/HTTP.c
@@ -130,7 +130,9 @@ PUBLIC void HTSSLInitPRNG NOARGS
RAND_seed((unsigned char *)&pid, sizeof(pid));
/* Initialize system's random number generator */
RAND_bytes((unsigned char *)&seed, sizeof(long));
+#if !defined(__OpenBSD__)
lynx_srand(seed);
+#endif
while (RAND_status() == 0) {
/* Repeatedly seed the PRNG using the system's random number generator until it has been seeded with enough data */
l = lynx_rand();
diff --git a/gnu/usr.bin/lynx/aclocal.m4 b/gnu/usr.bin/lynx/aclocal.m4
index 0d9f34f1331..e3bafacf77b 100644
--- a/gnu/usr.bin/lynx/aclocal.m4
+++ b/gnu/usr.bin/lynx/aclocal.m4
@@ -3277,7 +3277,7 @@ dnl which usually is only 16-bits.
AC_DEFUN([CF_SRAND],[
AC_CACHE_CHECK(for random-integer functions, cf_cv_srand_func,[
cf_cv_srand_func=unknown
-for cf_func in srandom/random srand48/lrand48 srand/rand
+for cf_func in arc4random srandom/random srand48/lrand48 srand/rand
do
cf_srand_func=`echo $cf_func | sed -e 's%/.*%%'`
cf_rand_func=`echo $cf_func | sed -e 's%.*/%%'`
@@ -3288,7 +3288,7 @@ AC_TRY_LINK([
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
-],[long seed = 1; $cf_srand_func(seed); seed = $cf_rand_func()],
+],[long seed = 1; seed = $cf_rand_func()],
[cf_cv_srand_func=$cf_func
break])
done
@@ -3300,6 +3300,10 @@ if test "$cf_cv_srand_func" != unknown ; then
cf_cv_rand_max=RAND_MAX
cf_rand_max=16
;;
+ arc4random)
+ cf_cv_rand_max=0xFFFFFFFFUL
+ cf_rand_max=32
+ ;;
*)
cf_cv_rand_max=INT_MAX
cf_rand_max=31
diff --git a/gnu/usr.bin/lynx/configure b/gnu/usr.bin/lynx/configure
index 632c12dd800..69c95848e4a 100644
--- a/gnu/usr.bin/lynx/configure
+++ b/gnu/usr.bin/lynx/configure
@@ -11387,7 +11387,7 @@ if eval "test \"`echo '$''{'cf_cv_srand_func'+set}'`\" = set"; then
else
cf_cv_srand_func=unknown
-for cf_func in srandom/random srand48/lrand48 srand/rand
+for cf_func in arc4random srandom/random srand48/lrand48 srand/rand
do
cf_srand_func=`echo $cf_func | sed -e 's%/.*%%'`
cf_rand_func=`echo $cf_func | sed -e 's%.*/%%'`
@@ -11403,7 +11403,7 @@ cat > conftest.$ac_ext <<EOF
#endif
int main() {
-long seed = 1; $cf_srand_func(seed); seed = $cf_rand_func()
+long seed = 1; seed = $cf_rand_func()
; return 0; }
EOF
if { (eval echo configure:11410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
@@ -11432,6 +11432,10 @@ else
cf_cv_rand_max=RAND_MAX
cf_rand_max=16
;;
+ arc4random)
+ cf_cv_rand_max=0xFFFFFFFFUL
+ cf_rand_max=32
+ ;;
*)
cf_cv_rand_max=INT_MAX
cf_rand_max=31
diff --git a/gnu/usr.bin/lynx/src/HTML.c b/gnu/usr.bin/lynx/src/HTML.c
index b819215e669..1a508067830 100644
--- a/gnu/usr.bin/lynx/src/HTML.c
+++ b/gnu/usr.bin/lynx/src/HTML.c
@@ -2104,7 +2104,8 @@ PRIVATE int HTML_start_element ARGS6(
int enval = 2;
column = HText_getCurrentColumn(me->text);
- if (present[HTML_TAB_TO]) {
+ if (present[HTML_TAB_TO] &&
+ value[HTML_TAB_TO] && *value[HTML_TAB_TO]) {
/*
* TO has priority over INDENT if both are present. - FM
*/
diff --git a/gnu/usr.bin/lynx/src/LYUtils.c b/gnu/usr.bin/lynx/src/LYUtils.c
index 869ebf141e6..c89af7bbf93 100644
--- a/gnu/usr.bin/lynx/src/LYUtils.c
+++ b/gnu/usr.bin/lynx/src/LYUtils.c
@@ -3272,7 +3272,9 @@ PRIVATE int fmt_tempname ARGS3(
*/
#ifdef USE_RAND_TEMPNAME
if (first) {
+#if !defined(__OpenBSD__)
lynx_srand((unsigned)((long)time((time_t *)0) + (long)result));
+#endif
first = FALSE;
}