diff options
author | 2016-05-28 15:46:43 +0000 | |
---|---|---|
committer | 2016-05-28 15:46:43 +0000 | |
commit | ae95b2a9e951ed5805863e6c1ae0324109d178d3 (patch) | |
tree | d156b31c6b5dde98ba12853b407680134dc57a56 | |
parent | Use getaddrinfo() instead of the non-standard gethostbyname2(). (diff) | |
download | wireguard-openbsd-ae95b2a9e951ed5805863e6c1ae0324109d178d3.tar.xz wireguard-openbsd-ae95b2a9e951ed5805863e6c1ae0324109d178d3.zip |
Hoist the opendev() call before the pledge because it can ioctl() when
the provided path is bogus or not a device.
ok deraadt
-rw-r--r-- | sbin/disklabel/disklabel.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index 0e06cdffa2a..ab32f047e35 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.214 2015/11/25 17:17:38 krw Exp $ */ +/* $OpenBSD: disklabel.c,v 1.215 2016/05/28 15:46:43 beck Exp $ */ /* * Copyright (c) 1987, 1993 @@ -191,6 +191,12 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + dkname = argv[0]; + f = opendev(dkname, (op == READ ? O_RDONLY : O_RDWR), OPENDEV_PART, + &specname); + if (f < 0) + err(4, "%s", specname); + if (op == EDIT || op == EDITOR || aflag) { if (pledge("stdio rpath wpath cpath disklabel proc exec", NULL) == -1) err(1, "pledge"); @@ -206,12 +212,6 @@ main(int argc, char *argv[]) aflag))) usage(); - dkname = argv[0]; - f = opendev(dkname, (op == READ ? O_RDONLY : O_RDWR), OPENDEV_PART, - &specname); - if (f < 0) - err(4, "%s", specname); - if (autotable != NULL) parse_autotable(autotable); |