Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6-0]: src/sys/kern Pull up following revision(s) (requested by ri...



details:   https://anonhg.NetBSD.org/src/rev/4be4ab09682d
branches:  netbsd-6-0
changeset: 775003:4be4ab09682d
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Nov 03 15:31:15 2014 +0000

description:
Pull up following revision(s) (requested by riastradh in ticket #1118):
        sys/kern/kern_rndq.c: revision 1.27
        sys/kern/kern_rndpool.c: revision 1.7
buf is not guaranteed to be aligned; don't *(uint32_t *) it in kern_rndq.c.
done is not guaranteed to be aligned; don't *(uint32_t *) it in kern_rndpool.c.

diffstat:

 sys/kern/kern_rndpool.c |   7 +++----
 sys/kern/kern_rndq.c    |  12 +++++++-----
 2 files changed, 10 insertions(+), 9 deletions(-)

diffs (75 lines):

diff -r e311f10e7368 -r 4be4ab09682d sys/kern/kern_rndpool.c
--- a/sys/kern/kern_rndpool.c   Mon Nov 03 15:13:30 2014 +0000
+++ b/sys/kern/kern_rndpool.c   Mon Nov 03 15:31:15 2014 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: kern_rndpool.c,v 1.1.2.1 2012/04/20 23:35:20 riz Exp $        */
+/*      $NetBSD: kern_rndpool.c,v 1.1.2.1.4.1 2014/11/03 15:31:15 msaitoh Exp $        */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndpool.c,v 1.1.2.1 2012/04/20 23:35:20 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndpool.c,v 1.1.2.1.4.1 2014/11/03 15:31:15 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -191,8 +191,7 @@
        buf = p;
 
        for (; len > 3; len -= 4) {
-               val = *((u_int32_t *)buf);
-
+               (void)memcpy(&val, buf, 4);
                rndpool_add_one_word(rp, val);
                buf += 4;
        }
diff -r e311f10e7368 -r 4be4ab09682d sys/kern/kern_rndq.c
--- a/sys/kern/kern_rndq.c      Mon Nov 03 15:13:30 2014 +0000
+++ b/sys/kern/kern_rndq.c      Mon Nov 03 15:31:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_rndq.c,v 1.1.2.2.4.1 2013/02/08 20:28:22 riz Exp $        */
+/*     $NetBSD: kern_rndq.c,v 1.1.2.2.4.2 2014/11/03 15:31:15 msaitoh Exp $    */
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.1.2.2.4.1 2013/02/08 20:28:22 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.1.2.2.4.2 2014/11/03 15:31:15 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/ioctl.h>
@@ -658,7 +658,8 @@
                u_int32_t entropy, uint32_t ts)
 {
        rnd_sample_t *state = NULL;
-       const uint32_t *dint = data;
+       const uint8_t *p = data;
+       uint32_t dint;
        int todo, done, filled = 0;
        SIMPLEQ_HEAD(, _rnd_sample_t) tmp_samples =
                        SIMPLEQ_HEAD_INITIALIZER(tmp_samples);
@@ -671,7 +672,7 @@
         * Loop over data packaging it into sample buffers.
         * If a sample buffer allocation fails, drop all data.
         */
-       todo = len / sizeof(*dint);
+       todo = len / sizeof(dint);
        for (done = 0; done < todo ; done++) {
                state = rs->state;
                if (state == NULL) {
@@ -683,7 +684,8 @@
                }
 
                state->ts[state->cursor] = ts;
-               state->values[state->cursor] = dint[done];
+               (void)memcpy(&dint, &p[done*4], 4);
+               state->values[state->cursor] = dint;
                state->cursor++;
 
                if (state->cursor == RND_SAMPLE_COUNT) {



Home | Main Index | Thread Index | Old Index