mkhybrid(8) does not seem to be maintained upstream. Here are a few
minor fixes to it:
- buffer overflows, spotted by -Wbounded. They are caused by the way
char name[] is defined in struct iso_directory_record in
src/iso9660.h; unfortunately too much of the code will require
adjustments, should the field be replaced with a sizeless array.
- always false comparisons on `unsigned char' architectures (arm,
powerpc).
Index: src/eltorito.c
===================================================================
RCS file: /OpenBSD/src/gnu/usr.sbin/mkhybrid/src/eltorito.c,v
retrieving revision 1.3
diff -u -p -r1.3 eltorito.c
--- src/eltorito.c 8 Mar 2008 15:36:12 -0000 1.3
+++ src/eltorito.c 3 Sep 2015 17:04:25 -0000
@@ -127,7 +127,7 @@ void FDECL1(get_torito_desc, struct elto
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));
Index: src/joliet.c
===================================================================
RCS file: /OpenBSD/src/gnu/usr.sbin/mkhybrid/src/joliet.c,v
retrieving revision 1.2
diff -u -p -r1.2 joliet.c
--- src/joliet.c 8 Mar 2008 15:36:12 -0000 1.2
+++ src/joliet.c 3 Sep 2015 17:04:25 -0000
@@ -229,7 +229,7 @@ static void FDECL1(get_joliet_vol_desc,
* 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.
Index: src/mkisofs.h
===================================================================
RCS file: /OpenBSD/src/gnu/usr.sbin/mkhybrid/src/mkisofs.h,v
retrieving revision 1.3
diff -u -p -r1.3 mkisofs.h
--- src/mkisofs.h 8 Aug 2013 05:30:23 -0000 1.3
+++ src/mkisofs.h 3 Sep 2015 17:04:25 -0000
@@ -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
Index: src/multi.c
===================================================================
RCS file: /OpenBSD/src/gnu/usr.sbin/mkhybrid/src/multi.c,v
retrieving revision 1.2
diff -u -p -r1.2 multi.c
--- src/multi.c 8 Mar 2008 15:36:12 -0000 1.2
+++ src/multi.c 3 Sep 2015 17:04:25 -0000
@@ -801,9 +801,9 @@ struct iso_directory_record * FDECL1(mer
* Get the location and size of the root directory.
*/
rootp = (struct iso_directory_record *)
- malloc(sizeof(struct iso_directory_record));
+ 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;
}
Index: src/name.c
===================================================================
RCS file: /OpenBSD/src/gnu/usr.sbin/mkhybrid/src/name.c,v
retrieving revision 1.2
diff -u -p -r1.2 name.c
--- src/name.c 8 Mar 2008 15:36:12 -0000 1.2
+++ src/name.c 3 Sep 2015 17:04:25 -0000
@@ -211,7 +211,7 @@ int FDECL3(iso9660_file_length,
}
if(current_length < 30)
{
- if( *pnt < 0 )
+ if( (signed char)*pnt < 0 )
{
*result++ = '_';
}
@@ -279,7 +279,7 @@ int FDECL3(iso9660_file_length,
switch (*pnt)
{
default:
- if( *pnt < 0 )
+ if( (signed char)*pnt < 0 )
{
*result++ = '_';
}
Index: src/tree.c
===================================================================
RCS file: /OpenBSD/src/gnu/usr.sbin/mkhybrid/src/tree.c,v
retrieving revision 1.5
diff -u -p -r1.5 tree.c
--- src/tree.c 8 Aug 2013 03:16:13 -0000 1.5
+++ src/tree.c 3 Sep 2015 17:04:26 -0000
@@ -1037,7 +1037,7 @@ FDECL3(insert_file_entry,struct director
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,7 @@ FDECL3(insert_file_entry,struct director
#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)) {
+ if ((x_hfs = hfs_matches(short_name)) || hfs_matches(whole_path)) {
if (verbose > 1) {
fprintf(stderr, "Hidden from HFS tree: %s\n", whole_path);
}
Index: src/write.c
===================================================================
RCS file: /OpenBSD/src/gnu/usr.sbin/mkhybrid/src/write.c,v
retrieving revision 1.3
diff -u -p -r1.3 write.c
--- src/write.c 8 Mar 2008 15:36:12 -0000 1.3
+++ src/write.c 3 Sep 2015 17:04:26 -0000
@@ -1330,7 +1330,7 @@ static int FDECL1(pvd_write, FILE *, out
*/
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 *, out
* 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 *, out
*/
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;