diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-03-09 12:55:19 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2016-03-09 12:55:19 +0000 |
commit | 915c509003ff173d8d3f034de16f7b505d93d4f9 (patch) | |
tree | e35d393762c1e222e22347f53fe4039f16beb5ea /sbin/pdisk/pdisk.c | |
parent | afe90395aba5328f0328b03814da91176cdefc51 (diff) |
Accept only character special devices rather than generating a core
dump on the attempt to get a disklabel from a regular file.
Regular files have not been acceptable as the 'disk' for some time,
and pledging changed the consequences from a somewhat obscure error
message to an abort().
Issue discovered by espie@.
ok natano@
Diffstat (limited to 'sbin/pdisk/pdisk.c')
-rw-r--r-- | sbin/pdisk/pdisk.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c index 2327a95615a..ae2e4929a76 100644 --- a/sbin/pdisk/pdisk.c +++ b/sbin/pdisk/pdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pdisk.c,v 1.84 2016/02/02 15:23:07 krw Exp $ */ +/* $OpenBSD: pdisk.c,v 1.85 2016/03/09 12:55:18 krw Exp $ */ /* * pdisk - an editor for Apple format partition tables @@ -113,9 +113,8 @@ main(int argc, char **argv) if (fstat(fd, &st) == -1) err(1, "can't fstat %s", *argv); - if (!S_ISCHR(st.st_mode) && !S_ISREG(st.st_mode)) - errx(1, "%s is not a character device or a regular file", - *argv); + if (!S_ISCHR(st.st_mode)) + errx(1, "%s is not a character device", *argv); if (ioctl(fd, DIOCGPDINFO, &dl) == -1) err(1, "can't get disklabel for %s", *argv); |