Files

49 lines
1.2 KiB
Diff

Backport a bugfix from 3.02a07:
- mkisofs: when stripping off "./" and "//" from graft points, mkisofs
now uses ovstrcpy() that supports to copy overlapping strings as Mac OS
has a strlcpy() that fails with overlapping strings.
Thanks to a hint from Colin Finck <colin@reactos.org>
--- mkisofs/mkisofs.c.orig 2015-01-01 08:19:51.000000000 -0600
+++ mkisofs/mkisofs.c 2020-09-30 13:30:39.000000000 -0500
@@ -1443,6 +1443,7 @@
char **short_namep, BOOL do_insert));
EXPORT void *e_malloc __PR((size_t size));
EXPORT char *e_strdup __PR((const char *s));
+LOCAL void ovstrcpy __PR((char *p2, char *p1));
LOCAL void checkarch __PR((char *name));
LOCAL void
@@ -3680,7 +3681,11 @@
while (*xpnt == PATH_SEPARATOR) {
xpnt++;
}
- strlcpy(graft_point, xpnt, glen);
+ /*
+ * The string becomes shorter, there is no need to check
+ * the length. Make sure to support overlapping strings.
+ */
+ ovstrcpy(graft_point, xpnt);
} while (xpnt > graft_point);
if (node) {
@@ -3853,6 +3858,18 @@
return (ret);
}
+/*
+ * A strcpy() that works with overlapping buffers
+ */
+LOCAL void
+ovstrcpy(p2, p1)
+ register char *p2;
+ register char *p1;
+{
+ while ((*p2++ = *p1++) != '\0')
+ ;
+}
+
LOCAL void
checkarch(name)
char *name;