diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2003-04-06 03:02:45 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2003-04-06 03:02:45 +0000 |
commit | 8fea19bc2c0fc1c5cf2c6e45177ffd1ca7c92517 (patch) | |
tree | 1c9542a2e075429f5f803751b5ce426c9b5486f5 /sys/scsi | |
parent | 3d0f8ae22e810aef00073168f02cfe53c32996e8 (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@
Diffstat (limited to 'sys/scsi')
-rw-r--r-- | sys/scsi/cd.c | 8 | ||||
-rw-r--r-- | sys/scsi/sd.c | 8 |
2 files changed, 8 insertions, 8 deletions
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; |