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/arch | |
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/arch')
-rw-r--r-- | sys/arch/hp300/dev/hd.c | 4 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/disksubr.c | 4 | ||||
-rw-r--r-- | sys/arch/vax/mba/hp.c | 5 |
3 files changed, 7 insertions, 6 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. */ |