diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-07-07 03:02:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-07-07 03:02:52 +0000 |
commit | b6f917e38f32ad82988462d315c2cc55cf1bf038 (patch) | |
tree | 5cdca187b9174c4ca42772ef5bc06e07679f4f92 /sys/arch/powerpc | |
parent | 0718e94007d14d484b2502651a72956542b4a5e0 (diff) |
fix chrtoblk() so that it returne ENODEV for entries beyond the end of the table
Diffstat (limited to 'sys/arch/powerpc')
-rw-r--r-- | sys/arch/powerpc/powerpc/conf.c | 37 |
1 files changed, 8 insertions, 29 deletions
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))); } /* |