summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--entropy.c17
2 files changed, 10 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 9dd054dda..fb3ac0484 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,7 @@
23 - (stevesk) scp.c: use mysignal() for updateprogressmeter() handler. 23 - (stevesk) scp.c: use mysignal() for updateprogressmeter() handler.
24 - (djm) SA_INTERRUPT is the converse of SA_RESTART, apply it only for 24 - (djm) SA_INTERRUPT is the converse of SA_RESTART, apply it only for
25 SIGALRM. 25 SIGALRM.
26 - (djm) Move entropy.c over to mysignal()
26 27
2720010217 2820010217
28 - (bal) OpenBSD Sync: 29 - (bal) OpenBSD Sync:
@@ -4030,4 +4031,4 @@
4030 - Wrote replacements for strlcpy and mkdtemp 4031 - Wrote replacements for strlcpy and mkdtemp
4031 - Released 1.0pre1 4032 - Released 1.0pre1
4032 4033
4033$Id: ChangeLog,v 1.795 2001/02/18 04:18:43 djm Exp $ 4034$Id: ChangeLog,v 1.796 2001/02/18 04:28:11 djm Exp $
diff --git a/entropy.c b/entropy.c
index fb81d7822..ed8b8db2c 100644
--- a/entropy.c
+++ b/entropy.c
@@ -33,12 +33,13 @@
33#endif /* HAVE_FLOATINGPOINT_H */ 33#endif /* HAVE_FLOATINGPOINT_H */
34 34
35#include "ssh.h" 35#include "ssh.h"
36#include "misc.h"
36#include "xmalloc.h" 37#include "xmalloc.h"
37#include "atomicio.h" 38#include "atomicio.h"
38#include "pathnames.h" 39#include "pathnames.h"
39#include "log.h" 40#include "log.h"
40 41
41RCSID("$Id: entropy.c,v 1.27 2001/02/18 01:44:29 djm Exp $"); 42RCSID("$Id: entropy.c,v 1.28 2001/02/18 04:28:12 djm Exp $");
42 43
43#ifndef offsetof 44#ifndef offsetof
44# define offsetof(type, member) ((size_t) &((type *)0)->member) 45# define offsetof(type, member) ((size_t) &((type *)0)->member)
@@ -72,7 +73,7 @@ int get_random_bytes(unsigned char *buf, int len)
72 char msg[2]; 73 char msg[2];
73 struct sockaddr_un addr; 74 struct sockaddr_un addr;
74 int addr_len, rval, errors; 75 int addr_len, rval, errors;
75 struct sigaction nsa, osa; 76 mysig_t old_sigpipe;
76 77
77 /* Sanity checks */ 78 /* Sanity checks */
78 if (sizeof(EGD_SOCKET) > sizeof(addr.sun_path)) 79 if (sizeof(EGD_SOCKET) > sizeof(addr.sun_path))
@@ -85,9 +86,7 @@ int get_random_bytes(unsigned char *buf, int len)
85 strlcpy(addr.sun_path, EGD_SOCKET, sizeof(addr.sun_path)); 86 strlcpy(addr.sun_path, EGD_SOCKET, sizeof(addr.sun_path));
86 addr_len = offsetof(struct sockaddr_un, sun_path) + sizeof(EGD_SOCKET); 87 addr_len = offsetof(struct sockaddr_un, sun_path) + sizeof(EGD_SOCKET);
87 88
88 memset(&nsa, 0, sizeof(nsa)); 89 old_sigpipe = mysignal(SIGPIPE, SIG_IGN);
89 nsa.sa_handler = SIG_IGN;
90 (void) sigaction(SIGPIPE, &nsa, &osa);
91 90
92 errors = rval = 0; 91 errors = rval = 0;
93reopen: 92reopen:
@@ -131,7 +130,7 @@ reopen:
131 130
132 rval = 1; 131 rval = 1;
133done: 132done:
134 (void) sigaction(SIGPIPE, &osa, NULL); 133 mysignal(SIG_PIPE, old_sigpipe);
135 if (fd != -1) 134 if (fd != -1)
136 close(fd); 135 close(fd);
137 return(rval); 136 return(rval);
@@ -790,14 +789,14 @@ prng_seed_cleanup(void *junk)
790void 789void
791seed_rng(void) 790seed_rng(void)
792{ 791{
793 void *old_sigchld_handler; 792 mysig_t old_sigchld_handler;
794 793
795 if (!prng_initialised) 794 if (!prng_initialised)
796 fatal("RNG not initialised"); 795 fatal("RNG not initialised");
797 796
798 /* Make sure some other sigchld handler doesn't reap our entropy */ 797 /* Make sure some other sigchld handler doesn't reap our entropy */
799 /* commands */ 798 /* commands */
800 old_sigchld_handler = signal(SIGCHLD, SIG_DFL); 799 old_sigchld_handler = mysignal(SIGCHLD, SIG_DFL);
801 800
802 debug("Seeded RNG with %i bytes from programs", (int)stir_from_programs()); 801 debug("Seeded RNG with %i bytes from programs", (int)stir_from_programs());
803 debug("Seeded RNG with %i bytes from system calls", (int)stir_from_system()); 802 debug("Seeded RNG with %i bytes from system calls", (int)stir_from_system());
@@ -805,7 +804,7 @@ seed_rng(void)
805 if (!RAND_status()) 804 if (!RAND_status())
806 fatal("Not enough entropy in RNG"); 805 fatal("Not enough entropy in RNG");
807 806
808 signal(SIGCHLD, old_sigchld_handler); 807 mysignal(SIGCHLD, old_sigchld_handler);
809 808
810 if (!RAND_status()) 809 if (!RAND_status())
811 fatal("Couldn't initialise builtin random number generator -- exiting."); 810 fatal("Couldn't initialise builtin random number generator -- exiting.");