Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/a91c90c7996c
branches:  netbsd-6-1
changeset: 776004:a91c90c7996c
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Nov 03 15:30:10 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 af844d1c2dfd -r a91c90c7996c sys/kern/kern_rndpool.c
--- a/sys/kern/kern_rndpool.c   Mon Nov 03 15:10:38 2014 +0000
+++ b/sys/kern/kern_rndpool.c   Mon Nov 03 15:30:10 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.6.1 2014/11/03 15:30:10 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.6.1 2014/11/03 15:30:10 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 af844d1c2dfd -r a91c90c7996c sys/kern/kern_rndq.c
--- a/sys/kern/kern_rndq.c      Mon Nov 03 15:10:38 2014 +0000
+++ b/sys/kern/kern_rndq.c      Mon Nov 03 15:30:10 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_rndq.c,v 1.1.2.5 2013/02/08 20:28:07 riz Exp $    */
+/*     $NetBSD: kern_rndq.c,v 1.1.2.5.2.1 2014/11/03 15:30:10 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.5 2013/02/08 20:28:07 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.1.2.5.2.1 2014/11/03 15:30:10 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/ioctl.h>
@@ -663,7 +663,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);
@@ -676,7 +677,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) {
@@ -688,7 +689,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