For unknown CPU, if family >= CPU_MAXFAMILY set family to CPU_MINFAMILY instead

of CPU_MAXFAMILY. This effectively causes to downgrade to i386 class
instead of a nonexistant class, and overrunning  classnames[] by one.
Coverity ID 1472.
This commit is contained in:
bouyer 2006-03-27 20:59:35 +00:00
parent d6d75eaf5d
commit 03999c340c
2 changed files with 8 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: identcpu.c,v 1.30 2006/03/20 05:21:27 briggs Exp $ */ /* $NetBSD: identcpu.c,v 1.31 2006/03/27 20:59:35 bouyer Exp $ */
/*- /*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc. * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.30 2006/03/20 05:21:27 briggs Exp $"); __KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.31 2006/03/27 20:59:35 bouyer Exp $");
#include "opt_cputype.h" #include "opt_cputype.h"
#include "opt_enhanced_speedstep.h" #include "opt_enhanced_speedstep.h"
@ -1163,8 +1163,8 @@ identifycpu(struct cpu_info *ci)
vendorname = (char *)&ci->ci_vendor[0]; vendorname = (char *)&ci->ci_vendor[0];
else else
vendorname = "Unknown"; vendorname = "Unknown";
if (family > CPU_MAXFAMILY) if (family >= CPU_MAXFAMILY)
family = CPU_MAXFAMILY; family = CPU_MINFAMILY;
class = family - 3; class = family - 3;
modifier = ""; modifier = "";
name = ""; name = "";

View File

@ -1,4 +1,4 @@
/* $NetBSD: identcpu.c,v 1.10 2006/03/07 23:08:14 jld Exp $ */ /* $NetBSD: identcpu.c,v 1.11 2006/03/27 20:59:35 bouyer Exp $ */
/* NetBSD: identcpu.c,v 1.16 2004/04/05 02:09:41 mrg Exp */ /* NetBSD: identcpu.c,v 1.16 2004/04/05 02:09:41 mrg Exp */
/*- /*-
@ -38,7 +38,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.10 2006/03/07 23:08:14 jld Exp $"); __KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.11 2006/03/27 20:59:35 bouyer Exp $");
#include "opt_cputype.h" #include "opt_cputype.h"
@ -1097,8 +1097,8 @@ identifycpu(struct cpu_info *ci)
vendorname = (char *)&ci->ci_vendor[0]; vendorname = (char *)&ci->ci_vendor[0];
else else
vendorname = "Unknown"; vendorname = "Unknown";
if (family > CPU_MAXFAMILY) if (family >= CPU_MAXFAMILY)
family = CPU_MAXFAMILY; family = CPU_MINFAMILY;
class = family - 3; class = family - 3;
modifier = ""; modifier = "";
name = ""; name = "";