> Looks good to me, though I wonder if the "check for char less than
> zero" tests should be replaced with isascii((unsigned char)x), as that
> smells like the intent.
Indeed, especially since other ctype functions are used after that test.
New diff also including feedback from jca@. Also, we do not need to
embed the GNU getopt implementation anymore, since libc's getopt grew
support for long options quite many years ago.
Index: mkhybrid/Makefile
===================================================================
RCS file: /cvs/src/gnu/usr.sbin/mkhybrid/mkhybrid/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- mkhybrid/Makefile 8 Aug 2013 18:11:36 -0000 1.6
+++ mkhybrid/Makefile 9 Sep 2015 13:47:04 -0000
@@ -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 \
Index: src/eltorito.c
===================================================================
RCS file: /cvs/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 9 Sep 2015 13:47:04 -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: /cvs/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 9 Sep 2015 13:47:04 -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: /cvs/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 9 Sep 2015 13:47:04 -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: /cvs/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 9 Sep 2015 13:47:04 -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: /cvs/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 9 Sep 2015 13:47:04 -0000
@@ -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++ = '_';
}
Index: src/tree.c
===================================================================
RCS file: /cvs/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 9 Sep 2015 13:47:04 -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,8 @@ 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)) {
+ 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);
}
Index: src/write.c
===================================================================
RCS file: /cvs/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 9 Sep 2015 13:47:04 -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;