]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Corrected _rnd_get_event().
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 19 Nov 2013 13:04:09 +0000 (14:04 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 27 Nov 2013 10:41:43 +0000 (11:41 +0100)
lib/nettle/rnd-common.c
lib/nettle/rnd-common.h
lib/nettle/rnd-fips.c

index da8d4f08f402ae4fd8c47ba4e70aa10343057480..2d7ff8455b7f4bd6959f8ce85abe1159ed6bd9e7 100644 (file)
 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;
 }
index 9c63f50645eb3b89eabcff8141ef4958e32fdcb3..f3918415eb96bbde507ea6129d447c27210ad224 100644 (file)
@@ -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);
 
index fb7146b050280508de0b92522ea4149f7c6a6652..692d012684c1255f42a162da0bf3ed601d9b13fb 100644 (file)
@@ -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;