Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/crypto/opencrypto Avoid variable lenght buffers to hel...
details: https://anonhg.NetBSD.org/src/rev/0b3ce80266a2
branches: trunk
changeset: 354353:0b3ce80266a2
user: martin <martin%NetBSD.org@localhost>
date: Tue Jun 13 08:16:16 2017 +0000
description:
Avoid variable lenght buffers to help the stack protector (hopefully no
functional change)
diffstat:
tests/crypto/opencrypto/h_ioctl.c | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diffs (83 lines):
diff -r cc914d4ba116 -r 0b3ce80266a2 tests/crypto/opencrypto/h_ioctl.c
--- a/tests/crypto/opencrypto/h_ioctl.c Tue Jun 13 08:10:52 2017 +0000
+++ b/tests/crypto/opencrypto/h_ioctl.c Tue Jun 13 08:16:16 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_ioctl.c,v 1.1 2017/06/09 06:09:02 knakahara Exp $ */
+/* $NetBSD: h_ioctl.c,v 1.2 2017/06/13 08:16:16 martin Exp $ */
/*-
* Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -69,11 +69,11 @@
test_ngsession(int fd)
{
int ret;
- int cs_count = 2;
struct crypt_sgop sg;
- struct session_n_op css[cs_count];
+ struct session_n_op css[2];
+ const size_t cs_count = __arraycount(css);
- for (int i = 0; i < cs_count; i++) {
+ for (size_t i = 0; i < cs_count; i++) {
struct session_n_op *cs = &css[i];
memset(cs, 0, sizeof(*cs));
@@ -100,9 +100,9 @@
test_nfsession(int fd)
{
int ret;
- int sid_count = 2;
struct crypt_sfop sf;
- u_int32_t sids[sid_count];
+ u_int32_t sids[2];
+ const size_t sid_count = __arraycount(sids);
memset(sids, 0, sizeof(sids));
memset(&sf, 0, sizeof(sf));
@@ -124,11 +124,11 @@
test_ncryptm(int fd)
{
int ret;
- int cs_count = 2;
struct crypt_mop mop;
- struct crypt_n_op css[cs_count];
+ struct crypt_n_op css[2];
+ const size_t cs_count = __arraycount(css);
- for (int i = 0; i < cs_count; i++) {
+ for (size_t i = 0; i < cs_count; i++) {
struct crypt_n_op *cs;
cs = &css[i];
@@ -157,11 +157,11 @@
test_ncryptretm(int fd)
{
int ret;
- int req_count = 2;
struct session_op cs;
struct crypt_mop mop;
- struct crypt_n_op cnos[req_count];
+ struct crypt_n_op cnos[2];
+ const size_t req_count = __arraycount(cnos);
unsigned char cno_dst[req_count][AES_CIPHER_LEN];
struct cryptret cret;
@@ -177,7 +177,7 @@
return ret;
}
- for (int i = 0; i < req_count; i++) {
+ for (size_t i = 0; i < req_count; i++) {
struct crypt_n_op *cno = &cnos[i];
memset(cno, 0, sizeof(*cno));
@@ -196,7 +196,7 @@
if (ret < 0)
fprintf(stderr, "failed: CIOCNCRYPTM\n");
- for (int i = 0; i < req_count; i++) {
+ for (size_t i = 0; i < req_count; i++) {
struct crypt_result *cr = &crs[i];
memset(cr, 0, sizeof(*cr));
Home |
Main Index |
Thread Index |
Old Index