summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-07-07 03:02:52 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-07-07 03:02:52 +0000
commitb6f917e38f32ad82988462d315c2cc55cf1bf038 (patch)
tree5cdca187b9174c4ca42772ef5bc06e07679f4f92 /sys/arch
parent0718e94007d14d484b2502651a72956542b4a5e0 (diff)
fix chrtoblk() so that it returne ENODEV for entries beyond the end of the table
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/alpha/alpha/conf.c6
-rw-r--r--sys/arch/amiga/amiga/conf.c11
-rw-r--r--sys/arch/arc/arc/conf.c47
-rw-r--r--sys/arch/arm32/arm32/conf.c22
-rw-r--r--sys/arch/atari/atari/conf.c12
-rw-r--r--sys/arch/hp300/hp300/conf.c6
-rw-r--r--sys/arch/i386/i386/conf.c7
-rw-r--r--sys/arch/kbus/kbus/conf.c11
-rw-r--r--sys/arch/mac68k/mac68k/conf.c22
-rw-r--r--sys/arch/pc532/pc532/conf.c5
-rw-r--r--sys/arch/pmax/pmax/conf.c3
-rw-r--r--sys/arch/powerpc/powerpc/conf.c37
-rw-r--r--sys/arch/sparc/sparc/conf.c13
-rw-r--r--sys/arch/sun3/sun3/conf.c18
-rw-r--r--sys/arch/vax/vax/conf.c15
-rw-r--r--sys/arch/wgrisc/wgrisc/conf.c45
16 files changed, 74 insertions, 206 deletions
diff --git a/sys/arch/alpha/alpha/conf.c b/sys/arch/alpha/alpha/conf.c
index 7820d125f46..d8f6c833243 100644
--- a/sys/arch/alpha/alpha/conf.c
+++ b/sys/arch/alpha/alpha/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.14 1997/11/23 05:21:53 mickey Exp $ */
+/* $OpenBSD: conf.c,v 1.15 1998/07/07 03:02:29 deraadt Exp $ */
/* $NetBSD: conf.c,v 1.16 1996/10/18 21:26:57 cgd Exp $ */
/*-
@@ -245,7 +245,6 @@ static int chrtoblktbl[] = {
/* 35 */ NODEV,
/* 36 */ 0,
/* 37 */ 4,
- /* 38 */ NODEV,
};
/*
@@ -257,7 +256,8 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= nchrdev)
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
return (NODEV);
blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
diff --git a/sys/arch/amiga/amiga/conf.c b/sys/arch/amiga/amiga/conf.c
index 196e24b7750..6b29db09211 100644
--- a/sys/arch/amiga/amiga/conf.c
+++ b/sys/arch/amiga/amiga/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.20 1998/04/26 22:30:57 niklas Exp $ */
+/* $OpenBSD: conf.c,v 1.21 1998/07/07 03:02:30 deraadt Exp $ */
/* $NetBSD: conf.c,v 1.42 1997/01/07 11:35:03 mrg Exp $ */
/*-
@@ -263,11 +263,12 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= nchrdev)
- return(NODEV);
- blkmaj = chrtoblktab[major(dev)];
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
+ return (NODEV);
+ blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
- return(NODEV);
+ return (NODEV);
return (makedev(blkmaj, minor(dev)));
}
diff --git a/sys/arch/arc/arc/conf.c b/sys/arch/arc/arc/conf.c
index e0b0730ac97..7be82736197 100644
--- a/sys/arch/arc/arc/conf.c
+++ b/sys/arch/arc/arc/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.20 1998/05/06 05:11:16 imp Exp $ */
+/* $OpenBSD: conf.c,v 1.21 1998/07/07 03:02:32 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)conf.c 8.2 (Berkeley) 11/14/93
- * $Id: conf.c,v 1.20 1998/05/06 05:11:16 imp Exp $
+ * $Id: conf.c,v 1.21 1998/07/07 03:02:32 deraadt Exp $
*/
#include <sys/param.h>
@@ -282,45 +282,10 @@ static int chrtoblktbl[MAXDEV] = {
/* 20 */ NODEV,
/* 21 */ NODEV,
/* 22 */ 8,
- /* 23 */ NODEV,
- /* 24 */ NODEV,
- /* 25 */ NODEV,
- /* 26 */ NODEV,
- /* 27 */ NODEV,
- /* 28 */ NODEV,
- /* 29 */ NODEV,
- /* 30 */ NODEV,
- /* 31 */ NODEV,
- /* 32 */ NODEV,
- /* 33 */ NODEV,
- /* 34 */ NODEV,
- /* 35 */ NODEV,
- /* 36 */ NODEV,
- /* 37 */ NODEV,
- /* 38 */ NODEV,
- /* 39 */ NODEV,
- /* 40 */ NODEV,
- /* 41 */ NODEV,
- /* 42 */ NODEV,
- /* 43 */ NODEV,
- /* 44 */ NODEV,
- /* 45 */ NODEV,
- /* 46 */ NODEV,
- /* 47 */ NODEV,
- /* 48 */ NODEV,
- /* 49 */ NODEV,
- /* 50 */ NODEV,
- /* 51 */ NODEV,
- /* 52 */ NODEV,
- /* 53 */ NODEV,
- /* 54 */ NODEV,
- /* 55 */ NODEV,
- /* 56 */ NODEV,
};
+
/*
* Routine to convert from character to block device number.
- *
- * A minimal stub routine can always return NODEV.
*/
dev_t
chrtoblk(dev)
@@ -328,7 +293,11 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= MAXDEV || (blkmaj = chrtoblktbl[major(dev)]) == NODEV)
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
+ return (NODEV);
+ blkmaj = chrtoblktbl[major(dev)];
+ if (blkmaj == NODEV)
return (NODEV);
return (makedev(blkmaj, minor(dev)));
}
diff --git a/sys/arch/arm32/arm32/conf.c b/sys/arch/arm32/arm32/conf.c
index 8a6f8f6ac94..d6403058df2 100644
--- a/sys/arch/arm32/arm32/conf.c
+++ b/sys/arch/arm32/arm32/conf.c
@@ -355,38 +355,20 @@ static int chrtoblktbl[] = {
/* 24 */ 24,
/* 25 */ 25,
/* 26 */ 26,
- /* 27 */ NODEV,
- /* 28 */ NODEV,
- /* 29 */ NODEV,
- /* 30 */ NODEV,
- /* 31 */ NODEV,
- /* 32 */ NODEV,
- /* 33 */ NODEV,
- /* 34 */ NODEV,
- /* 35 */ NODEV,
- /* 36 */ NODEV,
- /* 37 */ NODEV,
- /* 38 */ NODEV,
- /* 39 */ NODEV,
- /* 40 */ NODEV,
- /* 41 */ NODEV,
- /* 42 */ NODEV,
- /* 43 */ NODEV,
};
/*
* Convert a character device number to a block device number.
*/
-
dev_t
chrtoblk(dev)
dev_t dev;
{
int blkmaj;
- if (major(dev) >= nchrdev)
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
return (NODEV);
-
blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
return (NODEV);
diff --git a/sys/arch/atari/atari/conf.c b/sys/arch/atari/atari/conf.c
index 692c36a5630..f982504898c 100644
--- a/sys/arch/atari/atari/conf.c
+++ b/sys/arch/atari/atari/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.10 1997/11/23 05:21:54 mickey Exp $ */
+/* $OpenBSD: conf.c,v 1.11 1998/07/07 03:02:35 deraadt Exp $ */
/*
* Copyright (c) 1991 The Regents of the University of California.
@@ -259,7 +259,6 @@ static int chrtoblktab[] = {
/* 25 */ NODEV,
/* 26 */ NODEV,
/* 27 */ 13,
- /* 28 */ NODEV,
};
/*
@@ -271,11 +270,12 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= nchrdev)
- return(NODEV);
- blkmaj = chrtoblktab[major(dev)];
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
+ return (NODEV);
+ blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
- return(NODEV);
+ return (NODEV);
return (makedev(blkmaj, minor(dev)));
}
diff --git a/sys/arch/hp300/hp300/conf.c b/sys/arch/hp300/hp300/conf.c
index e3c65ccc2a6..cebfe9c4d9b 100644
--- a/sys/arch/hp300/hp300/conf.c
+++ b/sys/arch/hp300/hp300/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.18 1997/11/23 05:22:53 mickey Exp $ */
+/* $OpenBSD: conf.c,v 1.19 1998/07/07 03:02:36 deraadt Exp $ */
/* $NetBSD: conf.c,v 1.39 1997/05/12 08:17:53 thorpej Exp $ */
/*-
@@ -266,7 +266,6 @@ static int chrtoblktbl[] = {
/* 32 */ NODEV,
/* 33 */ NODEV,
/* 34 */ 8,
- /* 35 */ NODEV,
};
/*
@@ -278,7 +277,8 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= nchrdev)
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
return (NODEV);
blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
diff --git a/sys/arch/i386/i386/conf.c b/sys/arch/i386/i386/conf.c
index 1b44e0d0e30..3d3bba2c83b 100644
--- a/sys/arch/i386/i386/conf.c
+++ b/sys/arch/i386/i386/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.43 1998/04/01 20:16:41 matthieu Exp $ */
+/* $OpenBSD: conf.c,v 1.44 1998/07/07 03:02:38 deraadt Exp $ */
/* $NetBSD: conf.c,v 1.75 1996/05/03 19:40:20 christos Exp $ */
/*
@@ -329,8 +329,6 @@ static int chrtoblktbl[] = {
/* 45 */ NODEV,
/* 46 */ NODEV,
/* 47 */ 17,
- /* 48 */ NODEV,
- /* 49 */ NODEV,
};
/*
@@ -342,7 +340,8 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= nchrdev)
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
return (NODEV);
blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
diff --git a/sys/arch/kbus/kbus/conf.c b/sys/arch/kbus/kbus/conf.c
index d9c33931d4a..00a833e13de 100644
--- a/sys/arch/kbus/kbus/conf.c
+++ b/sys/arch/kbus/kbus/conf.c
@@ -389,14 +389,6 @@ static int chrtoblktbl[] = {
/*108 */ NODEV,
/*109 */ NODEV,
/*110 */ 8,
- /*111 */ NODEV,
- /*112 */ NODEV,
- /*113 */ NODEV,
- /*114 */ NODEV,
- /*115 */ NODEV,
- /*116 */ NODEV,
- /*117 */ NODEV,
- /*118 */ NODEV,
};
/*
@@ -408,7 +400,8 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= nchrdev)
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
return (NODEV);
blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
diff --git a/sys/arch/mac68k/mac68k/conf.c b/sys/arch/mac68k/mac68k/conf.c
index 6a3b54a8da2..a929252f44b 100644
--- a/sys/arch/mac68k/mac68k/conf.c
+++ b/sys/arch/mac68k/mac68k/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.16 1997/11/23 05:21:55 mickey Exp $ */
+/* $OpenBSD: conf.c,v 1.17 1998/07/07 03:02:41 deraadt Exp $ */
/* $NetBSD: conf.c,v 1.41 1997/02/11 07:35:49 scottr Exp $ */
/*
@@ -220,17 +220,6 @@ static int chrtoblktab[] = {
/* 18 */ NODEV,
/* 19 */ 8,
/* 20 */ 9,
- /* 21 */ NODEV,
- /* 22 */ NODEV,
- /* 23 */ NODEV,
- /* 24 */ NODEV,
- /* 25 */ NODEV,
- /* 26 */ NODEV,
- /* 27 */ NODEV,
- /* 28 */ NODEV,
- /* 29 */ NODEV,
- /* 30 */ NODEV,
- /* 31 */ NODEV,
};
dev_t
@@ -239,11 +228,12 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= nchrdev)
- return NODEV;
- blkmaj = chrtoblktab[major(dev)];
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
+ return (NODEV);
+ blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
- return NODEV;
+ return (NODEV);
return (makedev(blkmaj, minor(dev)));
}
diff --git a/sys/arch/pc532/pc532/conf.c b/sys/arch/pc532/pc532/conf.c
index 4917d9be9af..44dd560c008 100644
--- a/sys/arch/pc532/pc532/conf.c
+++ b/sys/arch/pc532/pc532/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.8 1997/11/23 05:21:57 mickey Exp $ */
+/* $OpenBSD: conf.c,v 1.9 1998/07/07 03:02:42 deraadt Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -188,7 +188,8 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= nchrdev)
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
return (NODEV);
blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
diff --git a/sys/arch/pmax/pmax/conf.c b/sys/arch/pmax/pmax/conf.c
index 11c0a8fa9fd..a847aad329d 100644
--- a/sys/arch/pmax/pmax/conf.c
+++ b/sys/arch/pmax/pmax/conf.c
@@ -387,7 +387,8 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= nchrdev)
+ if (major(dev) >= nchrdev ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
return (NODEV);
blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
diff --git a/sys/arch/powerpc/powerpc/conf.c b/sys/arch/powerpc/powerpc/conf.c
index e75d6e113ca..105d405cff9 100644
--- a/sys/arch/powerpc/powerpc/conf.c
+++ b/sys/arch/powerpc/powerpc/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.7 1998/05/29 04:15:38 rahnds Exp $ */
+/* $OpenBSD: conf.c,v 1.8 1998/07/07 03:02:45 deraadt Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -232,29 +232,6 @@ static int chrtoblktbl[] = {
/* 15 */ NODEV,
/* 16 */ NODEV,
/* 17 */ 17,
- /* 18 */ NODEV,
- /* 19 */ NODEV,
- /* 20 */ NODEV,
- /* 21 */ NODEV,
- /* 22 */ NODEV,
- /* 23 */ NODEV,
- /* 24 */ NODEV,
- /* 25 */ NODEV,
- /* 26 */ NODEV,
- /* 27 */ NODEV,
- /* 28 */ NODEV,
- /* 29 */ NODEV,
- /* 30 */ NODEV,
- /* 31 */ NODEV,
- /* 32 */ NODEV,
- /* 33 */ NODEV,
- /* 34 */ NODEV,
- /* 35 */ NODEV,
- /* 36 */ NODEV,
- /* 37 */ NODEV,
- /* 38 */ NODEV,
- /* 39 */ NODEV,
- /* 40 */ NODEV,
};
/*
@@ -266,11 +243,13 @@ chrtoblk(dev)
{
int major;
- if ((major = major(dev)) >= nchrdev)
- return NODEV;
- if ((major = chrtoblktbl[major]) == NODEV)
- return NODEV;
- return makedev(major, minor(dev));
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
+ return (NODEV);
+ blkmaj = chrtoblktbl[major(dev)];
+ if (blkmaj == NODEV)
+ return (NODEV);
+ return (makedev(blkmaj, minor(dev)));
}
/*
diff --git a/sys/arch/sparc/sparc/conf.c b/sys/arch/sparc/sparc/conf.c
index 8a727ce7817..cc81ccc73fb 100644
--- a/sys/arch/sparc/sparc/conf.c
+++ b/sys/arch/sparc/sparc/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.15 1998/05/20 19:29:21 deraadt Exp $ */
+/* $OpenBSD: conf.c,v 1.16 1998/07/07 03:02:47 deraadt Exp $ */
/* $NetBSD: conf.c,v 1.40 1996/04/11 19:20:03 thorpej Exp $ */
/*
@@ -387,14 +387,6 @@ static int chrtoblktbl[] = {
/*108 */ NODEV,
/*109 */ NODEV,
/*110 */ 8,
- /*111 */ NODEV,
- /*112 */ NODEV,
- /*113 */ NODEV,
- /*114 */ NODEV,
- /*115 */ NODEV,
- /*116 */ NODEV,
- /*117 */ NODEV,
- /*118 */ NODEV,
};
/*
@@ -406,7 +398,8 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= nchrdev)
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
return (NODEV);
blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
diff --git a/sys/arch/sun3/sun3/conf.c b/sys/arch/sun3/sun3/conf.c
index 8b2c0c96cac..dba0177af94 100644
--- a/sys/arch/sun3/sun3/conf.c
+++ b/sys/arch/sun3/sun3/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.20 1997/02/22 21:09:15 kstailey Exp $ */
+/* $OpenBSD: conf.c,v 1.21 1998/07/07 03:02:48 deraadt Exp $ */
/* $NetBSD: conf.c,v 1.51 1996/11/04 16:16:09 gwr Exp $ */
/*-
@@ -273,19 +273,6 @@ static int chrtoblktbl[] = {
/* 56 */ NODEV,
/* 57 */ NODEV,
/* 58 */ 18,
- /* 59 */ NODEV,
- /* 60 */ NODEV,
- /* 61 */ NODEV,
- /* 62 */ NODEV,
- /* 63 */ NODEV,
- /* 64 */ NODEV,
- /* 65 */ NODEV,
- /* 66 */ NODEV,
- /* 67 */ NODEV,
- /* 68 */ NODEV,
- /* 69 */ NODEV,
- /* 70 */ NODEV,
- /* 71 */ NODEV,
};
/*
@@ -297,7 +284,8 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= nchrdev)
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
return (NODEV);
blkmaj = chrtoblktbl[major(dev)];
if (blkmaj == NODEV)
diff --git a/sys/arch/vax/vax/conf.c b/sys/arch/vax/vax/conf.c
index feaaffc5557..9b206a7e1f6 100644
--- a/sys/arch/vax/vax/conf.c
+++ b/sys/arch/vax/vax/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.14 1997/11/23 05:21:59 mickey Exp $ */
+/* $OpenBSD: conf.c,v 1.15 1998/07/07 03:02:50 deraadt Exp $ */
/* $NetBSD: conf.c,v 1.28 1997/02/04 19:13:17 ragge Exp $ */
/*-
@@ -515,18 +515,19 @@ int chrtoblktbl[] = {
21, /* 60 */
22, /* 61 */
23, /* 62 */
- NODEV, /* 63 */
- NODEV, /* 64 */
- NODEV, /* 65 */
};
int
chrtoblk(dev)
dev_t dev;
{
- if(major(dev)>=nchrdev) return(NODEV);
- return chrtoblktbl[major(dev)]==NODEV?NODEV:
- makedev(chrtoblktbl[major(dev)],minor(dev));
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
+ return (NODEV);
+ blkmaj = chrtoblktbl[major(dev)];
+ if (blkmaj == NODEV)
+ return (NODEV);
+ return (makedev(blkmaj, minor(dev)));
}
/*
diff --git a/sys/arch/wgrisc/wgrisc/conf.c b/sys/arch/wgrisc/wgrisc/conf.c
index 516e2018df1..7df87ae56f4 100644
--- a/sys/arch/wgrisc/wgrisc/conf.c
+++ b/sys/arch/wgrisc/wgrisc/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.4 1997/11/23 05:22:00 mickey Exp $ */
+/* $OpenBSD: conf.c,v 1.5 1998/07/07 03:02:51 deraadt Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)conf.c 8.2 (Berkeley) 11/14/93
- * $Id: conf.c,v 1.4 1997/11/23 05:22:00 mickey Exp $
+ * $Id: conf.c,v 1.5 1998/07/07 03:02:51 deraadt Exp $
*/
#include <sys/param.h>
@@ -249,41 +249,8 @@ static int chrtoblktbl[MAXDEV] = {
/* 20 */ NODEV,
/* 21 */ NODEV,
/* 22 */ 10,
- /* 23 */ NODEV,
- /* 24 */ NODEV,
- /* 25 */ NODEV,
- /* 26 */ NODEV,
- /* 27 */ NODEV,
- /* 28 */ NODEV,
- /* 29 */ NODEV,
- /* 30 */ NODEV,
- /* 31 */ NODEV,
- /* 32 */ NODEV,
- /* 33 */ NODEV,
- /* 34 */ NODEV,
- /* 35 */ NODEV,
- /* 36 */ NODEV,
- /* 37 */ NODEV,
- /* 38 */ NODEV,
- /* 39 */ NODEV,
- /* 40 */ NODEV,
- /* 41 */ NODEV,
- /* 42 */ NODEV,
- /* 43 */ NODEV,
- /* 44 */ NODEV,
- /* 45 */ NODEV,
- /* 46 */ NODEV,
- /* 47 */ NODEV,
- /* 48 */ NODEV,
- /* 49 */ NODEV,
- /* 50 */ NODEV,
- /* 51 */ NODEV,
- /* 52 */ NODEV,
- /* 53 */ NODEV,
- /* 54 */ NODEV,
- /* 55 */ NODEV,
- /* 56 */ NODEV,
};
+
/*
* Routine to convert from character to block device number.
*
@@ -294,7 +261,11 @@ chrtoblk(dev)
{
int blkmaj;
- if (major(dev) >= MAXDEV || (blkmaj = chrtoblktbl[major(dev)]) == NODEV)
+ if (major(dev) >= MAXDEV ||
+ major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]))
+ return (NODEV);
+ blkmaj = chrtoblktbl[major(dev)];
+ if (blkmaj == NODEV)
return (NODEV);
return (makedev(blkmaj, minor(dev)));
}