Source-Changes-HG archive

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

[src/trunk]: src/sbin/raidctl nspares is now unsigned. Validate and use as po...



details:   https://anonhg.NetBSD.org/src/rev/a0e2a46315aa
branches:  trunk
changeset: 459804:a0e2a46315aa
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Thu Sep 26 10:33:30 2019 +0000

description:
nspares is now unsigned. Validate and use as positive integer.

diffstat:

 sbin/raidctl/raidctl.c |  18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diffs (54 lines):

diff -r 2b777a152451 -r a0e2a46315aa sbin/raidctl/raidctl.c
--- a/sbin/raidctl/raidctl.c    Thu Sep 26 09:21:34 2019 +0000
+++ b/sbin/raidctl/raidctl.c    Thu Sep 26 10:33:30 2019 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: raidctl.c,v 1.69 2019/02/06 22:38:10 oster Exp $   */
+/*      $NetBSD: raidctl.c,v 1.70 2019/09/26 10:33:30 mlelstv Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.69 2019/02/06 22:38:10 oster Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.70 2019/09/26 10:33:30 mlelstv Exp $");
 #endif
 
 
@@ -430,7 +430,7 @@
        RF_DeviceConfig_t device_config;
        void *cfg_ptr;
        int is_clean;
-       int i;
+       int i, nspares;
 
        cfg_ptr = &device_config;
 
@@ -441,9 +441,13 @@
                printf("%20s: %s\n", device_config.devs[i].devname, 
                       device_status(device_config.devs[i].status));
        }
-       if (device_config.nspares > 0) {
+
+       nspares = uimin(device_config.nspares,
+                       __arraycount(device_config.spares));
+
+       if (nspares > 0) {
                printf("Spares:\n");
-               for(i=0; i < device_config.nspares; i++) {
+               for(i=0; i < nspares; i++) {
                        printf("%20s: %s\n",
                               device_config.spares[i].devname, 
                               device_status(device_config.spares[i].status));
@@ -461,8 +465,8 @@
                }
        }
 
-       if (device_config.nspares > 0) {
-               for(i=0; i < device_config.nspares; i++) {
+       if (nspares > 0) {
+               for(i=0; i < nspares; i++) {
                        if ((device_config.spares[i].status == 
                             rf_ds_optimal) ||
                            (device_config.spares[i].status == 



Home | Main Index | Thread Index | Old Index