summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2003-04-06 03:02:45 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2003-04-06 03:02:45 +0000
commit8fea19bc2c0fc1c5cf2c6e45177ffd1ca7c92517 (patch)
tree1c9542a2e075429f5f803751b5ce426c9b5486f5
parent3d0f8ae22e810aef00073168f02cfe53c32996e8 (diff)
The disklabel fields d_packname and d_typename are not null terminated strings
and should not be created or used as such. This fixes some instances of both behaviours, and sets the stage for some strcpy -> strncpy fixup. ok tdeval@ millert@ deraadt@
-rw-r--r--sys/arch/hp300/dev/hd.c4
-rw-r--r--sys/arch/mvme88k/mvme88k/disksubr.c4
-rw-r--r--sys/arch/vax/mba/hp.c5
-rw-r--r--sys/scsi/cd.c8
-rw-r--r--sys/scsi/sd.c8
5 files changed, 15 insertions, 14 deletions
diff --git a/sys/arch/hp300/dev/hd.c b/sys/arch/hp300/dev/hd.c
index 5db78c6702b..480af3eac60 100644
--- a/sys/arch/hp300/dev/hd.c
+++ b/sys/arch/hp300/dev/hd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hd.c,v 1.20 2002/12/25 20:56:59 miod Exp $ */
+/* $OpenBSD: hd.c,v 1.21 2003/04/06 03:02:43 krw Exp $ */
/* $NetBSD: rd.c,v 1.33 1997/07/10 18:14:08 kleink Exp $ */
/*
@@ -488,7 +488,7 @@ hdgetinfo(dev, rs, lp, spoofonly)
bzero((caddr_t)lp, sizeof *lp);
lp->d_type = DTYPE_HPIB;
strncpy(lp->d_typename, hdidentinfo[rs->sc_type].ri_desc,
- sizeof(lp->d_typename) - 1);
+ sizeof(lp->d_typename));
strcpy(lp->d_packname, "fictitious");
lp->d_secsize = DEV_BSIZE;
lp->d_rpm = 3600;
diff --git a/sys/arch/mvme88k/mvme88k/disksubr.c b/sys/arch/mvme88k/mvme88k/disksubr.c
index 3cd0fe76fb2..3786c5fee6e 100644
--- a/sys/arch/mvme88k/mvme88k/disksubr.c
+++ b/sys/arch/mvme88k/mvme88k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.17 2002/03/14 01:26:40 millert Exp $ */
+/* $OpenBSD: disksubr.c,v 1.18 2003/04/06 03:02:44 krw Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 1995 Dale Rahn.
@@ -740,7 +740,7 @@ printlp(lp, str)
printf("%s\n", str);
printf("magic1 %x\n", lp->d_magic);
printf("magic2 %x\n", lp->d_magic2);
- printf("typename %s\n", lp->d_typename);
+ printf("typename %.*s\n", (int)sizeof(lp->d_typename), lp->d_typename);
printf("secsize %x nsect %x ntrack %x ncylinders %x\n",
lp->d_secsize, lp->d_nsectors, lp->d_ntracks, lp->d_ncylinders);
printf("Num partitions %x\n", lp->d_npartitions);
diff --git a/sys/arch/vax/mba/hp.c b/sys/arch/vax/mba/hp.c
index d395379dbbc..e663a33dcbb 100644
--- a/sys/arch/vax/mba/hp.c
+++ b/sys/arch/vax/mba/hp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hp.c,v 1.12 2002/06/08 08:50:26 art Exp $ */
+/* $OpenBSD: hp.c,v 1.13 2003/04/06 03:02:44 krw Exp $ */
/* $NetBSD: hp.c,v 1.22 2000/02/12 16:09:33 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
@@ -165,7 +165,8 @@ hpattach(parent, self, aux)
if ((msg = readdisklabel(makedev(0, self->dv_unit * 8), hpstrategy,
dl, NULL)) != NULL)
printf(": %s", msg);
- printf(": %s, size = %d sectors\n", dl->d_typename, dl->d_secperunit);
+ printf(": %.*s, size = %d sectors\n",
+ (int)sizeof(dl->d_typename), dl->d_typename, dl->d_secperunit);
/*
* check if this was what we booted from.
*/
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index 2829df4a120..e7ce0a29e3b 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.c,v 1.67 2003/01/17 04:30:06 jason Exp $ */
+/* $OpenBSD: cd.c,v 1.68 2003/04/06 03:02:44 krw Exp $ */
/* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */
/*
@@ -1214,14 +1214,14 @@ cdgetdisklabel(dev, cd, lp, clp, spoofonly)
}
if (cd->sc_link->flags & SDEV_ATAPI) {
- strncpy(lp->d_typename, "ATAPI CD-ROM", sizeof(lp->d_typename) - 1);
+ strncpy(lp->d_typename, "ATAPI CD-ROM", sizeof(lp->d_typename));
lp->d_type = DTYPE_ATAPI;
} else {
- strncpy(lp->d_typename, "SCSI CD-ROM", sizeof(lp->d_typename) - 1);
+ strncpy(lp->d_typename, "SCSI CD-ROM", sizeof(lp->d_typename));
lp->d_type = DTYPE_SCSI;
}
- strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname) - 1);
+ strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
lp->d_secperunit = cd->params.disksize;
lp->d_rpm = 300;
lp->d_interleave = 1;
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index bfbb1e7dec8..0fd571bb659 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.56 2002/12/30 21:50:29 grange Exp $ */
+/* $OpenBSD: sd.c,v 1.57 2003/04/06 03:02:44 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -997,10 +997,10 @@ sdgetdisklabel(dev, sd, lp, clp, spoofonly)
lp->d_type = DTYPE_SCSI;
if (sd->type == T_OPTICAL)
strncpy(lp->d_typename, "SCSI optical",
- sizeof(lp->d_typename) - 1);
+ sizeof(lp->d_typename));
else
strncpy(lp->d_typename, "SCSI disk",
- sizeof(lp->d_typename) - 1);
+ sizeof(lp->d_typename));
if (strlen(sd->name.vendor) + strlen(sd->name.product) + 1 <
sizeof(lp->d_packname))
@@ -1008,7 +1008,7 @@ sdgetdisklabel(dev, sd, lp, clp, spoofonly)
sd->name.product);
else
strncpy(lp->d_packname, sd->name.product,
- sizeof(lp->d_packname) - 1);
+ sizeof(lp->d_packname));
lp->d_secperunit = sd->params.disksize;
lp->d_rpm = 3600;