Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Make kern.arandom truncate the output instead of fa...
details: https://anonhg.NetBSD.org/src/rev/7218af953355
branches: trunk
changeset: 931802:7218af953355
user: nia <nia%NetBSD.org@localhost>
date: Thu Apr 30 17:36:06 2020 +0000
description:
Make kern.arandom truncate the output instead of failing with ETOOBIG
when the requested data exceeds 256 bytes in size. The actual size of
the returned data is output to oldlenp.
This matches FreeBSD's behaviour and seems to be more in line with
what software in the wild expects.
"sounds reasonble" - Riastradh
diffstat:
sys/kern/subr_cprng.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r e48649383ecf -r 7218af953355 sys/kern/subr_cprng.c
--- a/sys/kern/subr_cprng.c Thu Apr 30 17:21:12 2020 +0000
+++ b/sys/kern/subr_cprng.c Thu Apr 30 17:36:06 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_cprng.c,v 1.36 2020/04/30 03:28:18 riastradh Exp $ */
+/* $NetBSD: subr_cprng.c,v 1.37 2020/04/30 17:36:06 nia Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.36 2020/04/30 03:28:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cprng.c,v 1.37 2020/04/30 17:36:06 nia Exp $");
#include <sys/types.h>
#include <sys/cprng.h>
@@ -172,7 +172,7 @@
* the past, so let's not break compatibility.
*/
if (*oldlenp > 256) /* size_t, so never negative */
- return E2BIG;
+ *oldlenp = 256;
/* Generate data. */
cprng_strong(user_cprng, buf, *oldlenp, 0);
Home |
Main Index |
Thread Index |
Old Index