Module Name: src
Committed By: tsutsui
Date: Thu Jan 2 18:45:24 UTC 2014
Modified Files:
src/sys/arch/luna68k/stand/boot: sc.c
Log Message:
Add bound check of a controller number in scrun().
Noticed by miod@openbsd.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/luna68k/stand/boot/sc.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/luna68k/stand/boot/sc.c
diff -u src/sys/arch/luna68k/stand/boot/sc.c:1.5 src/sys/arch/luna68k/stand/boot/sc.c:1.6
--- src/sys/arch/luna68k/stand/boot/sc.c:1.5 Thu Jan 2 17:47:23 2014
+++ src/sys/arch/luna68k/stand/boot/sc.c Thu Jan 2 18:45:24 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: sc.c,v 1.5 2014/01/02 17:47:23 tsutsui Exp $ */
+/* $NetBSD: sc.c,v 1.6 2014/01/02 18:45:24 tsutsui Exp $ */
/*
* Copyright (c) 1992 OMRON Corporation.
@@ -254,8 +254,14 @@ int
scrun(int ctlr, int slave, u_char *cdb, int cdblen, u_char *buf, int len,
volatile int *lock)
{
- struct scsi_softc *hs = &scsi_softc[ctlr];
- struct scsidevice *hd = (struct scsidevice *) hs->sc_hc->hp_addr;
+ struct scsi_softc *hs;
+ struct scsidevice *hd;
+
+ if (ctlr < 0 || ctlr >= NSC)
+ return 0;
+
+ hs = &scsi_softc[ctlr];
+ hd = (struct scsidevice *)hs->sc_hc->hp_addr;
if (hd->scsi_ssts & (SSTS_INITIATOR|SSTS_TARGET|SSTS_BUSY))
return(0);