stephenc / java-iso-tools

A fork of JIIC hosted on github
http://github.com/stephenc/java-iso-tools/wiki
GNU Lesser General Public License v2.1
78 stars 45 forks source link

locationFixups map is not collision proof resulting with a corrupted ISO file #42

Open nithril opened 7 months ago

nithril commented 7 months ago

Hello,

Issue created for the record as the project is not maintained anymore for future user hitting the issue.

In the method com.github.stephenc.javaisotools.iso9660.impl.ISO9660Factory#doFileFixup

The following code is using as a key the hashcode of an object (file.getContentID() returns the hashcode of file) that can be per contract not unique:

        if (locationFixups.containsKey(file.getContentID())) {
            location = ((Integer) locationFixups.get(file.getContentID())).intValue();
        } else {
            locationFixups.put(file.getContentID(), new Integer(location));
        }

There can be collision resulting in the reuse of a location for a file that is not actually the same.

jaksat0202 commented 7 months ago

Yes, it is a nasty bug that hits you when the number of files is large and there are no tests for this scenario.