From 4a058e82c533b4d5cb3c9b8e8ecc0224646c9680 Mon Sep 17 00:00:00 2001 From: oster Date: Sat, 14 Aug 1999 02:41:36 +0000 Subject: [PATCH] Correct and/or improve detection of bogus row/column values passed in via ioctls. --- sys/dev/raidframe/rf_netbsdkintf.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index e59a715713c1..be5f7731bc74 100644 --- a/sys/dev/raidframe/rf_netbsdkintf.c +++ b/sys/dev/raidframe/rf_netbsdkintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.25 1999/08/13 03:27:46 oster Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.26 1999/08/14 02:41:36 oster Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. * All rights reserved. @@ -888,14 +888,11 @@ raidioctl(dev, cmd, data, flag, p) } row = component_label->row; - printf("Row: %d\n",row); - if (row > raidPtrs[unit]->numRow) { - row = 0; /* XXX */ - } column = component_label->column; - printf("Column: %d\n",column); - if (column > raidPtrs[unit]->numCol) { - column = 0; /* XXX */ + + if ((row < 0) || (row >= raidPtrs[unit]->numRow) || + (column < 0) || (column >= raidPtrs[unit]->numCol)) { + return(EINVAL); } raidread_component_label( @@ -932,8 +929,8 @@ raidioctl(dev, cmd, data, flag, p) row = component_label->row; column = component_label->column; - if ((row < 0) || (row > raidPtrs[unit]->numRow) || - (column < 0) || (column > raidPtrs[unit]->numCol)) { + if ((row < 0) || (row >= raidPtrs[unit]->numRow) || + (column < 0) || (column >= raidPtrs[unit]->numCol)) { return(EINVAL); } @@ -1029,8 +1026,8 @@ raidioctl(dev, cmd, data, flag, p) row = component.row; column = component.column; printf("Rebuild: %d %d\n",row, column); - if ((row < 0) || (row > raidPtrs[unit]->numRow) || - (column < 0) || (column > raidPtrs[unit]->numCol)) { + if ((row < 0) || (row >= raidPtrs[unit]->numRow) || + (column < 0) || (column >= raidPtrs[unit]->numCol)) { return(EINVAL); } printf("Attempting a rebuild in place\n");