From: Nikos Mavrogiannopoulos Date: Tue, 19 Nov 2013 13:04:09 +0000 (+0100) Subject: Corrected _rnd_get_event(). X-Git-Tag: gnutls_3_3_0pre0~520^2~66 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5eed3ffcca2da878dba5b68a30d01b638d63d875;p=thirdparty%2Fgnutls.git Corrected _rnd_get_event(). --- diff --git a/lib/nettle/rnd-common.c b/lib/nettle/rnd-common.c index da8d4f08f4..2d7ff8455b 100644 --- a/lib/nettle/rnd-common.c +++ b/lib/nettle/rnd-common.c @@ -39,23 +39,22 @@ void _rnd_get_event(struct event_st *e) { static unsigned count = 0; - static struct event_st event; - gettime(&event.now); + gettime(&e->now); #ifdef HAVE_GETRUSAGE - if (getrusage(RUSAGE_SELF, &event.rusage) < 0) { + if (getrusage(RUSAGE_SELF, &e->rusage) < 0) { _gnutls_debug_log("getrusage failed: %s\n", strerror(errno)); abort(); } #endif - event.count = count++; #ifdef HAVE_GETPID - event.pid = getpid(); + e->pid = getpid(); #endif - event.err = errno; + e->count = count++; + e->err = errno; return; } diff --git a/lib/nettle/rnd-common.h b/lib/nettle/rnd-common.h index 9c63f50645..f3918415eb 100644 --- a/lib/nettle/rnd-common.h +++ b/lib/nettle/rnd-common.h @@ -39,7 +39,11 @@ struct event_st { #endif unsigned count; /* a running counter */ unsigned err; /* the last errno */ -}; +} +#ifdef __GNUC__ +__attribute__((packed)) +#endif +; void _rnd_get_event(struct event_st *e); diff --git a/lib/nettle/rnd-fips.c b/lib/nettle/rnd-fips.c index fb7146b050..692d012684 100644 --- a/lib/nettle/rnd-fips.c +++ b/lib/nettle/rnd-fips.c @@ -395,11 +395,11 @@ static int _rngfips_init(void** _ctx) { /* Basic initialization is required to initialize mutexes and do a few checks on the implementation. */ - static int initialized; + static int initialized = 0; struct fips_ctx* ctx; int ret; - if (initialized) + if (initialized != 0) return 0; initialized = 1;