Coverity CID 1534: Fix bogus code and array overruns.
This commit is contained in:
parent
a66f866e5e
commit
b7f5449dce
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dpt.c,v 1.46 2005/12/24 23:41:33 perry Exp $ */
|
||||
/* $NetBSD: dpt.c,v 1.47 2006/04/14 20:43:11 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
@ -78,7 +78,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: dpt.c,v 1.46 2005/12/24 23:41:33 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: dpt.c,v 1.47 2006/04/14 20:43:11 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -330,7 +330,8 @@ dpt_init(struct dpt_softc *sc, const char *intrstr)
|
||||
bus_dma_segment_t seg;
|
||||
struct eata_cfg *ec;
|
||||
struct dpt_ccb *ccb;
|
||||
char model[16];
|
||||
char model[__arraycount(ei->ei_model) + __arraycount(ei->ei_suffix) + 1];
|
||||
char vendor[__arraycount(ei->ei_vendor) + 1];
|
||||
|
||||
ec = &sc->sc_ec;
|
||||
snprintf(dpt_sig.dsDescription, sizeof(dpt_sig.dsDescription),
|
||||
@ -424,14 +425,17 @@ dpt_init(struct dpt_softc *sc, const char *intrstr)
|
||||
* dpt0: interrupting at irq 10
|
||||
* dpt0: 64 queued commands, 1 channel(s), adapter on ID(s) 7
|
||||
*/
|
||||
for (i = 0; ei->ei_vendor[i] != ' ' && i < 8; i++)
|
||||
;
|
||||
ei->ei_vendor[i] = '\0';
|
||||
for (i = 0; ei->ei_vendor[i] != ' ' && i < __arraycount(ei->ei_vendor);
|
||||
i++)
|
||||
vendor[i] = ei->ei_vendor[i];
|
||||
vendor[i] = '\0';
|
||||
|
||||
for (i = 0; ei->ei_model[i] != ' ' && i < 7; i++)
|
||||
model[i] = ei->ei_model[i];
|
||||
for (j = 0; ei->ei_suffix[j] != ' ' && j < 7; i++, j++)
|
||||
for (i = 0; ei->ei_model[i] != ' ' && i < __arraycount(ei->ei_model);
|
||||
i++)
|
||||
model[i] = ei->ei_model[i];
|
||||
for (j = 0; ei->ei_suffix[j] != ' ' && j < __arraycount(ei->ei_suffix);
|
||||
i++, j++)
|
||||
model[i] = ei->ei_suffix[j];
|
||||
model[i] = '\0';
|
||||
|
||||
/* Find the marketing name for the board. */
|
||||
@ -439,7 +443,7 @@ dpt_init(struct dpt_softc *sc, const char *intrstr)
|
||||
if (memcmp(ei->ei_model + 2, dpt_cname[i], 4) == 0)
|
||||
break;
|
||||
|
||||
aprint_normal("%s %s (%s)\n", ei->ei_vendor, dpt_cname[i + 1], model);
|
||||
aprint_normal("%s %s (%s)\n", vendor, dpt_cname[i + 1], model);
|
||||
|
||||
if (intrstr != NULL)
|
||||
aprint_normal("%s: interrupting at %s\n", sc->sc_dv.dv_xname,
|
||||
|
Loading…
Reference in New Issue
Block a user