From e9bbb736c557df2cb9edd193f52892ed534f31fe Mon Sep 17 00:00:00 2001 From: isaki Date: Thu, 12 Jan 2017 14:24:53 +0000 Subject: [PATCH] Fix the possibility of off-by-one on the grammer. Reported by coypu. Currently it never happens because type is (minor number % 7) and the arraycount of fd_types[] is 8. I.e., it is a dead code... However, when the capacity of the FDTYPE() changes or the arraycount of fd_types[] changes, this correction will be effective. --- sys/arch/x68k/dev/fd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/arch/x68k/dev/fd.c b/sys/arch/x68k/dev/fd.c index 8a94cc2e14b8..55af15d34e59 100644 --- a/sys/arch/x68k/dev/fd.c +++ b/sys/arch/x68k/dev/fd.c @@ -1,4 +1,4 @@ -/* $NetBSD: fd.c,v 1.118 2015/07/11 10:32:46 kamil Exp $ */ +/* $NetBSD: fd.c,v 1.119 2017/01/12 14:24:53 isaki Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.118 2015/07/11 10:32:46 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.119 2017/01/12 14:24:53 isaki Exp $"); #include "opt_ddb.h" #include "opt_m68k_arch.h" @@ -672,7 +672,7 @@ fd_dev_to_type(struct fd_softc *fd, dev_t dev) { size_t type = FDTYPE(dev); - if (type > __arraycount(fd_types)) + if (type >= __arraycount(fd_types)) return NULL; return &fd_types[type]; }