diff options
author | jkh <jkh@FreeBSD.org> | 1995-12-01 10:26:20 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-12-01 10:26:20 +0000 |
commit | e4661cdb21a6b64afbb72340f841f45eaefbcdcd (patch) | |
tree | 4519ba9b1b4d9fd1da3ea30016a0d5ed44b482a8 /usr.sbin/diskpart | |
parent | 128f61ea538bc4f09d2d800f1f0fe0cdea31c6b1 (diff) | |
download | FreeBSD-src-e4661cdb21a6b64afbb72340f841f45eaefbcdcd.zip FreeBSD-src-e4661cdb21a6b64afbb72340f841f45eaefbcdcd.tar.gz |
Account for newline in fgets(). Whoops!
Noticed by: peter
Diffstat (limited to 'usr.sbin/diskpart')
-rw-r--r-- | usr.sbin/diskpart/diskpart.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.sbin/diskpart/diskpart.c b/usr.sbin/diskpart/diskpart.c index 1c6638d..932b76a 100644 --- a/usr.sbin/diskpart/diskpart.c +++ b/usr.sbin/diskpart/diskpart.c @@ -375,8 +375,13 @@ promptfordisk(name) (void) fgets(buf, BUFSIZ, stdin); if (buf[0] == 0) dp->d_type = 1; - else + else { + int len = strlen(buf); + + if (buf[len - 1] == '\n') + buf[len - 1] = '\0'; dp->d_type = gettype(buf, dktypenames); + } if (dp->d_type >= 0) break; fprintf(stderr, "%s: unrecognized controller type\n", buf); |