summaryrefslogtreecommitdiffstats
path: root/usr.sbin/makefs
diff options
context:
space:
mode:
authoryasuoka <yasuoka@openbsd.org>2018-11-20 01:13:14 +0000
committeryasuoka <yasuoka@openbsd.org>2018-11-20 01:13:14 +0000
commitc8f48d9b1ea97c780a010188dff094ea5520467e (patch)
tree1784e80246f3a5ce1de091c6e2c1e406a44cafb9 /usr.sbin/makefs
parentFix compilation on alpha, where DEF_WEAK() really must be paired with (diff)
downloadwireguard-openbsd-c8f48d9b1ea97c780a010188dff094ea5520467e.tar.xz
wireguard-openbsd-c8f48d9b1ea97c780a010188dff094ea5520467e.zip
unveil(2) boot images which are specified by -o option. Also exit
with an error status when writing cd image fails. ok deraadt
Diffstat (limited to 'usr.sbin/makefs')
-rw-r--r--usr.sbin/makefs/cd9660.c11
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_eltorito.c4
2 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index 07aad8301ae..80e0f8dd3bf 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660.c,v 1.20 2017/04/06 19:09:45 natano Exp $ */
+/* $OpenBSD: cd9660.c,v 1.21 2018/11/20 01:13:14 yasuoka Exp $ */
/* $NetBSD: cd9660.c,v 1.53 2016/11/25 23:02:44 christos Exp $ */
/*
@@ -402,7 +402,7 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
fsinfo_t *fsopts)
{
int64_t startoffset;
- int numDirectories;
+ int ret, numDirectories;
uint64_t pathTableSectors;
int64_t firstAvailableSector;
int64_t totalSpace;
@@ -514,10 +514,13 @@ cd9660_makefs(const char *image, const char *dir, fsnode *root,
if (diskStructure->include_padding_areas)
diskStructure->totalSectors += 150;
- cd9660_write_image(diskStructure, image);
+ ret = cd9660_write_image(diskStructure, image);
/* Clean up data structures */
cd9660_free_structure(real_root);
+
+ if (ret == 0) /* cd9660_write_image() failed */
+ exit(1);
}
/* Generic function pointer - implement later */
@@ -1971,6 +1974,8 @@ cd9660_add_generic_bootimage(iso9660_disk *diskStructure, const char *bootimage)
diskStructure->generic_bootimage = estrdup(bootimage);
+ if (unveil(diskStructure->generic_bootimage, "r") == -1)
+ err(1, "unveil");
/* Get information about the file */
if (lstat(diskStructure->generic_bootimage, &stbuf) == -1)
err(1, "%s: lstat(\"%s\")", __func__,
diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.c b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
index cec8a8e3664..1c9b291a8b1 100644
--- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c
+++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660_eltorito.c,v 1.13 2017/11/07 00:22:40 yasuoka Exp $ */
+/* $OpenBSD: cd9660_eltorito.c,v 1.14 2018/11/20 01:13:15 yasuoka Exp $ */
/* $NetBSD: cd9660_eltorito.c,v 1.20 2013/01/28 21:03:28 christos Exp $ */
/*
@@ -119,6 +119,8 @@ cd9660_add_boot_disk(iso9660_disk *diskStructure, const char *boot_info)
free(temp);
+ if (unveil(new_image->filename, "r") == -1)
+ err(1, "unveil");
/* Get information about the file */
if (lstat(new_image->filename, &stbuf) == -1)
err(1, "%s: lstat(\"%s\")", __func__, new_image->filename);