Skip to content

Directory history corruption #4820

@egmontkob

Description

@egmontkob

Is there an existing issue for this?

  • I have searched the existing issues

Midnight Commander version and build configuration

4.8.33, git

Operating system

Linux

Is this issue reproducible using the latest version of Midnight Commander?

  • I confirm the issue is still reproducible with the latest version of Midnight Commander

How to reproduce

After experimenting with mc with different locales (UTF-8, ISO-8859-1, ISO-8859-2, KOI8-R, KOI8-U), entering directories with various accented characters in various encodings in their names, I ended up with lots of binary garbage in .local/share/mc/history, under [Dir Hist New Left/Right Panel].

This garbage, in turn, causes the panel directory history window to appear incorrectly: frame chars missing, garbage doesn't get removed when scrolling.

The garbage only appears in entries that do have accents in the filename. But it also appears in entries that were placed there long before I started testing mc with 8-bit locales.

Such garbage lines are easily 10'000+ bytes long.

While writing these lines I discovered how to reproduce:

It seems like whenever an entry can't be represented in the current locale, it undergoes a "to double UTF-8" conversion, effectively doubling the length of the string (related: #4819).

Just have an accent there somewhere in the list, and start mc with let's say hu_HU.ISO-8859-2 and ru_RU.KOI8-R locales alternatively.

Now that I was further playing with, mc startup time became noticeable (few seconds) as some of those lines grew to about 300'000 bytes. Then I wanted to create a screenshot of the broken panel but I got a segfault instead.

Expected behavior

Binary garbage shouldn't appear in the file.

Even if someone manually edits the file to contain binary garbage, the UI displaying them shouldn't completely fall apart.

Actual behavior

.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: configConfiguration INI filesprio: mediumHas the potential to affect progress

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions