Bug 283238 - makefs: cd9660 produces conflicting short paths
Summary: makefs: cd9660 produces conflicting short paths
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Ed Maste
URL: https://reviews.freebsd.org/D48251
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-10 18:37 UTC by Ed Maste
Modified: 2025-01-15 02:42 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2024-12-10 18:37:46 UTC
Rock ridge extensions add support for longer path and directory names than vanilla iso9660, but iso9660 data structures still need to be populated with unique, shortened versions of the longer names.

makefs has cd9660_handle_collisions() to find conflicting entries which uses cd9660_rename_filename() to choose a new name when a conflict is found. This is called for both file and directory names (and chooses a new name to resolve the conflict for both file and directory names) but the emitted data still has a conflict.

Demonstration:
```
$ mkdir -p test9660/this-is-a-directory-with-a-long-common-prefix-1 test9660/this-is-a-directory-with-a-long-common-prefix-2
$ makefs -t cd9660 -o rockridge test.iso test9660/
$ isoinfo -p -i test.iso
Setting input-charset to 'UTF-8' from locale.
Path table starts at block 18, size 86
   1:    1 14 
   2:    1 15 THIS_IS_A_DIRECTORY_WITH_A_LON
   3:    1 16 THIS_IS_A_DIRECTORY_WITH_A_LON
```
Comment 1 commit-hook freebsd_committer freebsd_triage 2024-12-30 19:50:48 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1f31d437428014e864bcce1223cf7017180e2608

commit 1f31d437428014e864bcce1223cf7017180e2608
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-12-30 15:01:06 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-12-30 19:48:44 +0000

    makefs: Fix cd9660 duplicate directory names

    Previously we could create cd9660 images with duplicate short (level 2)
    names.

    cd9660_level2_convert_filename used a 30-character limit (for files and
    directories), not including the '.' separator.  cd9660_rename_filename
    used a 31-character limit, including the '.'.  Directory names 31
    characters or longer (without '.') were shortened to 30 characters, and
    if a collision occurred cd9660_rename_filename uniquified them starting
    with the 31st character.  Unfortunately the directory record's name_len
    was already set, so the unique part of the name was stripped off.

    Directories are up to 31 d-characters (i.e., A-Z 0-9 and _); there is no
    provision for a '.' in a directory name.  Increase the name length limit
    to 31 for directories, and exclude '.'s.

    This name mapping and deduplication code is still fragile and convoluted
    and would beenfit from a more holistic effort.

    PR:             283238, 283112
    Reviewed by:    imp
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D48251

 usr.sbin/makefs/cd9660.c                     |  5 ++--
 usr.sbin/makefs/tests/makefs_cd9660_tests.sh | 39 ++++++++++++++++++++++++++--
 usr.sbin/makefs/tests/makefs_tests_common.sh |  2 +-
 3 files changed, 41 insertions(+), 5 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2025-01-14 21:08:21 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=40b11c1c16d85b3339be4c3c4fde2ef7fa36f3ff

commit 40b11c1c16d85b3339be4c3c4fde2ef7fa36f3ff
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-12-30 15:01:06 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2025-01-14 21:07:39 +0000

    makefs: Fix cd9660 duplicate directory names

    Previously we could create cd9660 images with duplicate short (level 2)
    names.

    cd9660_level2_convert_filename used a 30-character limit (for files and
    directories), not including the '.' separator.  cd9660_rename_filename
    used a 31-character limit, including the '.'.  Directory names 31
    characters or longer (without '.') were shortened to 30 characters, and
    if a collision occurred cd9660_rename_filename uniquified them starting
    with the 31st character.  Unfortunately the directory record's name_len
    was already set, so the unique part of the name was stripped off.

    Directories are up to 31 d-characters (i.e., A-Z 0-9 and _); there is no
    provision for a '.' in a directory name.  Increase the name length limit
    to 31 for directories, and exclude '.'s.

    This name mapping and deduplication code is still fragile and convoluted
    and would beenfit from a more holistic effort.

    PR:             283238, 283112
    Reviewed by:    imp
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D48251

    (cherry picked from commit 1f31d437428014e864bcce1223cf7017180e2608)

 usr.sbin/makefs/cd9660.c                     |  5 ++--
 usr.sbin/makefs/tests/makefs_cd9660_tests.sh | 39 ++++++++++++++++++++++++++--
 usr.sbin/makefs/tests/makefs_tests_common.sh |  2 +-
 3 files changed, 41 insertions(+), 5 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-01-15 02:33:59 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=79778b7aafc829e6f67cbf0d50a51836e69dc784

commit 79778b7aafc829e6f67cbf0d50a51836e69dc784
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-12-30 15:01:06 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2025-01-15 02:33:30 +0000

    makefs: Fix cd9660 duplicate directory names

    Previously we could create cd9660 images with duplicate short (level 2)
    names.

    cd9660_level2_convert_filename used a 30-character limit (for files and
    directories), not including the '.' separator.  cd9660_rename_filename
    used a 31-character limit, including the '.'.  Directory names 31
    characters or longer (without '.') were shortened to 30 characters, and
    if a collision occurred cd9660_rename_filename uniquified them starting
    with the 31st character.  Unfortunately the directory record's name_len
    was already set, so the unique part of the name was stripped off.

    Directories are up to 31 d-characters (i.e., A-Z 0-9 and _); there is no
    provision for a '.' in a directory name.  Increase the name length limit
    to 31 for directories, and exclude '.'s.

    This name mapping and deduplication code is still fragile and convoluted
    and would beenfit from a more holistic effort.

    PR:             283238, 283112
    Reviewed by:    imp
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D48251

    (cherry picked from commit 1f31d437428014e864bcce1223cf7017180e2608)
    (cherry picked from commit 40b11c1c16d85b3339be4c3c4fde2ef7fa36f3ff)

 usr.sbin/makefs/cd9660.c                     |  5 ++--
 usr.sbin/makefs/tests/makefs_cd9660_tests.sh | 39 ++++++++++++++++++++++++++--
 usr.sbin/makefs/tests/makefs_tests_common.sh |  2 +-
 3 files changed, 41 insertions(+), 5 deletions(-)