Opened 11 years ago

Closed 4 years ago

#43632 closed defect (fixed)

cdrtools @3.00_1: mkisofs receives abort trap on Mavericks host if -graft-points option is used

Reported by: galitsyn@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.2.1
Keywords: Cc:
Port: cdrtools

Description

Hi Guys!

The problem might be easily reproduced here if the next command line is executed:

mkisofs -graft-points a=b

This issue occurs on Mavericks (10.9.2) host only and I can't reproduce it on Mountain Lion (10.8.5) host.

I took a look to the ftp://ftp.berlios.de/pub/cdrecord/cdrtools-3.00.tar.bz2 sources and was able to fix it for myself. The patch below fixes the issue:

--- cdrtools-3.00/mkisofs/mkisofs.c.orig        2010-04-25 18:29:03.000000000 +0400
+++ cdrtools-3.00/mkisofs/mkisofs.c     2014-05-08 18:04:33.000000000 +0400
@@ -3235,15 +3235,15 @@
                /*
                 * Remove unwanted "./" & "/" sequences from start...
                 */
+               xpnt = graft_point;
                do {
-                       xpnt = graft_point;
                        while (xpnt[0] == '.' && xpnt[1] == '/')
                                xpnt += 2;
                        while (*xpnt == PATH_SEPARATOR) {
                                xpnt++;
                        }
-                       strlcpy(graft_point, xpnt, glen);
-               } while (xpnt > graft_point);
+               } while (graft_point++ < glen);
+               graft_point = xpnt;
 
                if (node) {
                        node = escstrcpy(nodename, nlen, ++node);

The problem was that strlcpy() used source and destination strings which overlap. Could you please take a look to the issue?

Thank you!

Attachments (1)

cdrtools-3.00-mkisofs.patch (659 bytes) - added by galitsyn@… 11 years ago.
Patch prevents mkisofs from receiving abort trap

Download all attachments as: .zip

Change History (7)

comment:1 Changed 11 years ago by galitsyn@…

Oh, the patch above is not correct =) The below one looks a bit better:

--- cdrtools-3.00/mkisofs/mkisofs.c.orig        2010-04-25 18:29:03.000000000 +0400
+++ cdrtools-3.00/mkisofs/mkisofs.c     2014-05-08 19:25:14.000000000 +0400
@@ -3235,15 +3235,16 @@
                /*
                 * Remove unwanted "./" & "/" sequences from start...
                 */
+               xpnt = graft_point;
+               size_t gidx = 0;
                do {
-                       xpnt = graft_point;
                        while (xpnt[0] == '.' && xpnt[1] == '/')
                                xpnt += 2;
                        while (*xpnt == PATH_SEPARATOR) {
                                xpnt++;
                        }
-                       strlcpy(graft_point, xpnt, glen);
-               } while (xpnt > graft_point);
+               } while ((xpnt[0] == '.' || xpnt[0] == '/') && gidx++ < glen);
+               graft_point = xpnt;
 
                if (node) {
                        node = escstrcpy(nodename, nlen, ++node);

comment:2 Changed 11 years ago by mf2k (Frank Schima)

Keywords: mkisofs removed
Owner: changed from macports-tickets@… to bytestorm@…

Please attach your patches to this ticket, not paste them inline.

In the future, please Cc the port maintainers (port info --maintainers cdrtools).

comment:3 Changed 11 years ago by galitsyn@…

Sure, sorry for that. Attaching the last patch.

Changed 11 years ago by galitsyn@…

Attachment: cdrtools-3.00-mkisofs.patch added

Patch prevents mkisofs from receiving abort trap

comment:4 Changed 10 years ago by mf2k (Frank Schima)

Owner: changed from bytestorm@… to macports-tickets@…

This port no longer has a maintainer. See #45212.

comment:5 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

The developer of cdrtools has fixed this in a different way in version 3.02a07. Per the entry in the file AN-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>

This version is not in MacPorts because it is an alpha and there has not been a new stable version after that. I'll see if I can backport the relevant change.

In the future please report such bugs directly to the developers of the affected software so that they can fix them.

comment:6 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: newclosed

In e39f07997a38d04422fceba50be9c239b3f0e764/macports-ports (master):

cdrtools: Use MacPorts flags and backport a bugfix

Closes: #34823
Closes: #43632

Note: See TracTickets for help on using tickets.