diff options
author | 2015-09-09 20:02:31 +0000 | |
---|---|---|
committer | 2015-09-09 20:02:31 +0000 | |
commit | 463a9bef2bdc2b5e044169c593f0d0a9af68f56d (patch) | |
tree | 38c9284eedbdfeb6a6a6ddce079f74c8d168ba91 | |
parent | Indent labels with a space so that diff -p is more friendly. (diff) | |
download | wireguard-openbsd-463a9bef2bdc2b5e044169c593f0d0a9af68f56d.tar.xz wireguard-openbsd-463a9bef2bdc2b5e044169c593f0d0a9af68f56d.zip |
Fix various buffer overflows (caused by the way struct iso_directory_record
is defined), and make this work on unsigned char platforms by using
isascii() instead of < 0.
While there, do not use the local getopt() implementation, as libc has had
getopt_long() support for years now.
With help from jca@ and guenther@. ok millert@, deraadt@ (on an earlier diff)
-rw-r--r-- | gnu/usr.sbin/mkhybrid/mkhybrid/Makefile | 4 | ||||
-rw-r--r-- | gnu/usr.sbin/mkhybrid/src/eltorito.c | 2 | ||||
-rw-r--r-- | gnu/usr.sbin/mkhybrid/src/joliet.c | 2 | ||||
-rw-r--r-- | gnu/usr.sbin/mkhybrid/src/mkisofs.h | 6 | ||||
-rw-r--r-- | gnu/usr.sbin/mkhybrid/src/multi.c | 5 | ||||
-rw-r--r-- | gnu/usr.sbin/mkhybrid/src/name.c | 4 | ||||
-rw-r--r-- | gnu/usr.sbin/mkhybrid/src/tree.c | 5 | ||||
-rw-r--r-- | gnu/usr.sbin/mkhybrid/src/write.c | 6 |
8 files changed, 17 insertions, 17 deletions
diff --git a/gnu/usr.sbin/mkhybrid/mkhybrid/Makefile b/gnu/usr.sbin/mkhybrid/mkhybrid/Makefile index 8412d35df26..83317bdbceb 100644 --- a/gnu/usr.sbin/mkhybrid/mkhybrid/Makefile +++ b/gnu/usr.sbin/mkhybrid/mkhybrid/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.6 2013/08/08 18:11:36 brad Exp $ +# $OpenBSD: Makefile,v 1.7 2015/09/09 20:02:31 miod Exp $ # NOTE: The mkhybrid distrib also makes an "mkisofs" which is the same binary # linked. When we know mkhybrid makes distrib CDs ok we should modify this @@ -14,7 +14,7 @@ CLEANFILES+= mkhybrid.8 SRCS= data.c block.c low.c lfile.c btree.c node.c record.c lvolume.c \ hfs.c file.c apprentice.c softmagic.c mkisofs.c tree.c write.c \ hash.c rock.c multi.c joliet.c match.c name.c eltorito.c \ - getopt.c getopt1.c apple.c volume.c desktop.c mac_label.c + apple.c volume.c desktop.c mac_label.c CFLAGS+=-DSYSTEM_ID_DEFAULT=\"OpenBSD\" -DAPPLE_HYB -DVANILLA_AUTOCONF \ -I${.CURDIR}/../src -I${.CURDIR}/../src/include \ diff --git a/gnu/usr.sbin/mkhybrid/src/eltorito.c b/gnu/usr.sbin/mkhybrid/src/eltorito.c index 501d3d65089..ccb44542118 100644 --- a/gnu/usr.sbin/mkhybrid/src/eltorito.c +++ b/gnu/usr.sbin/mkhybrid/src/eltorito.c @@ -127,7 +127,7 @@ void FDECL1(get_torito_desc, struct eltorito_boot_descriptor *, boot_desc) memset(boot_desc, 0, sizeof(*boot_desc)); boot_desc->id[0] = 0; - memcpy(boot_desc->id2, ISO_STANDARD_ID, sizeof(ISO_STANDARD_ID)); + memcpy(boot_desc->id2, ISO_STANDARD_ID, sizeof(ISO_STANDARD_ID) - 1); boot_desc->version[0] = 1; memcpy(boot_desc->system_id, EL_TORITO_ID, sizeof(EL_TORITO_ID)); diff --git a/gnu/usr.sbin/mkhybrid/src/joliet.c b/gnu/usr.sbin/mkhybrid/src/joliet.c index 780405d94b0..f33c45f998b 100644 --- a/gnu/usr.sbin/mkhybrid/src/joliet.c +++ b/gnu/usr.sbin/mkhybrid/src/joliet.c @@ -229,7 +229,7 @@ static void FDECL1(get_joliet_vol_desc, struct iso_primary_descriptor *, jvol_de * Set this one up. */ memcpy(jvol_desc->root_directory_record, &jroot_record, - sizeof(struct iso_directory_record)); + sizeof(jvol_desc->root_directory_record)); /* * Finally, we have a bunch of strings to convert to Unicode. diff --git a/gnu/usr.sbin/mkhybrid/src/mkisofs.h b/gnu/usr.sbin/mkhybrid/src/mkisofs.h index 71d35767eda..e7af9e66b3d 100644 --- a/gnu/usr.sbin/mkhybrid/src/mkisofs.h +++ b/gnu/usr.sbin/mkhybrid/src/mkisofs.h @@ -20,7 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* - * $Id: mkisofs.h,v 1.3 2013/08/08 05:30:23 guenther Exp $ + * $Id: mkisofs.h,v 1.4 2015/09/09 20:02:31 miod Exp $ */ /* APPLE_HYB James Pearson j.pearson@ge.ucl.ac.uk 12/3/99 */ @@ -486,8 +486,8 @@ extern void * DECL(e_malloc,(size_t)); #define NEED_SP 16 #define PREV_SESS_DEV (sizeof(dev_t) >= 4 ? 0x7ffffffd : 0x7ffd) -#define TABLE_INODE (sizeof(ino_t) >= 8 ? 0x7ffffffffffffffe : 0x7ffffffe) -#define UNCACHED_INODE (sizeof(ino_t) >= 8 ? 0x7fffffffffffffff : 0x7fffffff) +#define TABLE_INODE (sizeof(ino_t) >= 8 ? 0x7ffffffffffffffeLL : 0x7ffffffe) +#define UNCACHED_INODE (sizeof(ino_t) >= 8 ? 0x7fffffffffffffffLL : 0x7fffffff) #define UNCACHED_DEVICE (sizeof(dev_t) >= 4 ? 0x7fffffff : 0x7fff) #ifdef VMS diff --git a/gnu/usr.sbin/mkhybrid/src/multi.c b/gnu/usr.sbin/mkhybrid/src/multi.c index 96deaf711b3..42f26e9de75 100644 --- a/gnu/usr.sbin/mkhybrid/src/multi.c +++ b/gnu/usr.sbin/mkhybrid/src/multi.c @@ -800,10 +800,9 @@ struct iso_directory_record * FDECL1(merge_isofs, char *, path) /* * Get the location and size of the root directory. */ - rootp = (struct iso_directory_record *) - malloc(sizeof(struct iso_directory_record)); + rootp = calloc(1, sizeof(struct iso_directory_record)); - memcpy(rootp, pri->root_directory_record, sizeof(*rootp)); + memcpy(rootp, pri->root_directory_record, sizeof(pri->root_directory_record)); return rootp; } diff --git a/gnu/usr.sbin/mkhybrid/src/name.c b/gnu/usr.sbin/mkhybrid/src/name.c index bcc9511a790..4993fda6f62 100644 --- a/gnu/usr.sbin/mkhybrid/src/name.c +++ b/gnu/usr.sbin/mkhybrid/src/name.c @@ -211,7 +211,7 @@ int FDECL3(iso9660_file_length, } if(current_length < 30) { - if( *pnt < 0 ) + if(!isascii(*pnt)) { *result++ = '_'; } @@ -279,7 +279,7 @@ int FDECL3(iso9660_file_length, switch (*pnt) { default: - if( *pnt < 0 ) + if(!isascii(*pnt)) { *result++ = '_'; } diff --git a/gnu/usr.sbin/mkhybrid/src/tree.c b/gnu/usr.sbin/mkhybrid/src/tree.c index 071bbdb405b..4b9b8eee957 100644 --- a/gnu/usr.sbin/mkhybrid/src/tree.c +++ b/gnu/usr.sbin/mkhybrid/src/tree.c @@ -1037,7 +1037,7 @@ FDECL3(insert_file_entry,struct directory *, this_dir, int deep_flag; #ifdef APPLE_HYB int x_hfs = 0; - int htype; + int htype = 0; #endif /* APPLE_HYB */ status = stat_filter(whole_path, &statbuf); @@ -1263,7 +1263,8 @@ FDECL3(insert_file_entry,struct directory *, this_dir, #ifdef APPLE_HYB /* Should we exclude this HFS file ? - only works with -hfs */ if (!have_rsrc && apple_hyb && strcmp(short_name,".") && strcmp(short_name,"..")) { - if (x_hfs = hfs_matches(short_name) || hfs_matches(whole_path)) { + x_hfs = hfs_matches(short_name) || hfs_matches(whole_path); + if (x_hfs) { if (verbose > 1) { fprintf(stderr, "Hidden from HFS tree: %s\n", whole_path); } diff --git a/gnu/usr.sbin/mkhybrid/src/write.c b/gnu/usr.sbin/mkhybrid/src/write.c index 49b2ccd9aa6..681fe48e8ff 100644 --- a/gnu/usr.sbin/mkhybrid/src/write.c +++ b/gnu/usr.sbin/mkhybrid/src/write.c @@ -1330,7 +1330,7 @@ static int FDECL1(pvd_write, FILE *, outfile) */ memset(&vol_desc, 0, sizeof(vol_desc)); vol_desc.type[0] = ISO_VD_PRIMARY; - memcpy(vol_desc.id, ISO_STANDARD_ID, sizeof(ISO_STANDARD_ID)); + memcpy(vol_desc.id, ISO_STANDARD_ID, sizeof(ISO_STANDARD_ID) - 1); vol_desc.version[0] = 1; memset(vol_desc.system_id, ' ', sizeof(vol_desc.system_id)); @@ -1360,7 +1360,7 @@ static int FDECL1(pvd_write, FILE *, outfile) * Now we copy the actual root directory record */ memcpy(vol_desc.root_directory_record, &root_record, - sizeof(struct iso_directory_record) + 1); + sizeof(vol_desc.root_directory_record)); /* * The rest is just fluff. It looks nice to fill in many of these fields, @@ -1422,7 +1422,7 @@ static int FDECL1(evd_write, FILE *, outfile) */ memset(&evol_desc, 0, sizeof(evol_desc)); evol_desc.type[0] = ISO_VD_END; - memcpy(evol_desc.id, ISO_STANDARD_ID, sizeof(ISO_STANDARD_ID)); + memcpy(evol_desc.id, ISO_STANDARD_ID, sizeof(ISO_STANDARD_ID) - 1); evol_desc.version[0] = 1; xfwrite(&evol_desc, 1, 2048, outfile); last_extent_written += 1; |