Module Name: src
Committed By: riastradh
Date: Sat Jun 13 18:54:38 UTC 2020
Modified Files:
src/sys/arch/arm/sunxi: sun8i_crypto.c
Log Message:
Truncate hw.sun8icryptoN.rng queries to 4096 bytes.
...rather than fail entirely.
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sunxi/sun8i_crypto.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.14 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.15
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.14 Fri May 15 19:28:09 2020
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c Sat Jun 13 18:54:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sun8i_crypto.c,v 1.14 2020/05/15 19:28:09 maxv Exp $ */
+/* $NetBSD: sun8i_crypto.c,v 1.15 2020/06/13 18:54:38 riastradh Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.14 2020/05/15 19:28:09 maxv Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.15 2020/06/13 18:54:38 riastradh Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -1203,10 +1203,8 @@ sun8i_crypto_sysctl_rng(SYSCTLFN_ARGS)
return 0;
}
- /* Verify the output buffer size is reasonable. */
- size = *oldlenp;
- if (size > 4096) /* size_t, so never negative */
- return E2BIG;
+ /* Truncate to 4096 bytes. */
+ size = MIN(4096, *oldlenp);
if (size == 0)
return 0; /* nothing to do */