diff options
author | bde <bde@FreeBSD.org> | 1997-12-12 18:01:57 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1997-12-12 18:01:57 +0000 |
commit | 99e73a26e809af6c7debbfb64918e132c7dbb719 (patch) | |
tree | 8ad1cc46aca1ef4668f0c0b886227f579844a46c /usr.sbin | |
parent | cae319efef8cd4ebf8155a0d073086a5fa89d0d3 (diff) | |
download | FreeBSD-src-99e73a26e809af6c7debbfb64918e132c7dbb719.zip FreeBSD-src-99e73a26e809af6c7debbfb64918e132c7dbb719.tar.gz |
Fixed printing of and comparison with d_typename[]. It is not always
null terminated.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bad144/bad144.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.sbin/bad144/bad144.c b/usr.sbin/bad144/bad144.c index de890d2..ded783e 100644 --- a/usr.sbin/bad144/bad144.c +++ b/usr.sbin/bad144/bad144.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)bad144.c 8.2 (Berkeley) 4/27/95"; #endif static const char rcsid[] = - "$Id: bad144.c,v 1.15 1997/12/11 07:27:06 bde Exp $"; + "$Id: bad144.c,v 1.16 1997/12/12 17:58:31 bde Exp $"; #endif /* not lint */ /* @@ -332,8 +332,9 @@ main(argc, argv) sn = atoi(*argv++); argc--; if (sn < 0 || sn >= bend) { - printf("%d: out of range [0,%d) for disk %s\n", - sn, bend, dp->d_typename); + printf("%d: out of range [0,%d) for disk %.*s\n", + sn, bend, (int)sizeof(dp->d_typename), + dp->d_typename); errs++; continue; } @@ -703,10 +704,12 @@ format(fd, blk) int n; for (fp = formats; fp->f_name; fp++) - if (strcmp(dp->d_typename, fp->f_name) == 0) + if (strncmp(dp->d_typename, fp->f_name, sizeof(dp->d_typename)) + == 0 && strlen(fp->f_name) <= sizeof(dp->d_typename)) break; if (fp->f_name == 0) - errx(2, "don't know how to format %s disks", dp->d_typename); + errx(2, "don't know how to format %.*s disks", + (int)sizeof(dp->d_typename), dp->d_typename); if (buf && bufsize < fp->f_bufsize) { free(buf); buf = NULL; |