Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern done is not guaranteed to be aligned; don't *(uint3...
details: https://anonhg.NetBSD.org/src/rev/80c5297b499a
branches: trunk
changeset: 331477:80c5297b499a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Aug 11 14:07:55 2014 +0000
description:
done is not guaranteed to be aligned; don't *(uint32_t *) it.
diffstat:
sys/kern/kern_rndq.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diffs (47 lines):
diff -r 12dad24b17bb -r 80c5297b499a sys/kern/kern_rndq.c
--- a/sys/kern/kern_rndq.c Mon Aug 11 14:02:14 2014 +0000
+++ b/sys/kern/kern_rndq.c Mon Aug 11 14:07:55 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_rndq.c,v 1.26 2014/08/11 04:26:53 riastradh Exp $ */
+/* $NetBSD: kern_rndq.c,v 1.27 2014/08/11 14:07:55 riastradh Exp $ */
/*-
* Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.26 2014/08/11 04:26:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.27 2014/08/11 14:07:55 riastradh Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -816,7 +816,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;
int sample_count;
SIMPLEQ_HEAD(, _rnd_sample_t) tmp_samples =
@@ -828,7 +829,7 @@
RND_FLAG_COLLECT_VALUE))))) {
return;
}
- todo = len / sizeof(*dint);
+ todo = len / sizeof(dint);
/*
* Let's try to be efficient: if we are warm, and a source
* is adding entropy at a rate of at least 1 bit every 10 seconds,
@@ -874,7 +875,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 == sample_count) {
Home |
Main Index |
Thread Index |
Old Index