Package: trash-cli
Version: 0.17.1.14-5
Severity: important

Issue description: Sending files to trash using trash-cli causes system to 
stall and renders it irresponsive, if original filename of the file to be 
trashed exceeds a particular length.

Happened with some files downloaded from a website, which have been cut by the 
browser automatically to match the file name length restrictions of the file 
system (ext4).

Some testing turned out trash-cli tries obviously to append something to the 
filename, what clearly must fail if filename already has the max. length 
allowed.

Depending of the character set used, and depending whether special characters 
are involved, different length of names causes trouble in trash-cli.


Steps to reproduce:
touch files named precisely as follows, make sure to use the full line. (These 
are testing names merely for reproducing the issue)

   touch 
'АБВГДЕЁЖЗИЙКЛМНОПРЦТУФХЦШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРЦТУФХЦШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцшщъыьэю'

   touch 
'123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345'

These test file names are accepted by default ext4 file systems.

In case you have a different max allowed file name length on your ext4 file 
system make sure the names of the files to be trashed have the maximal length 
allowed or some few characters less.

Please note that the issue in a foreign character set (in the example this is 
Cyrillic, arbitrary choosen) the issue already present in half file name length 
as in English.

Now trash them using the default trash command provided by this package.

This will cause the system to stall with 100% CPU load and no longer respond to 
any input. Single way out seems to be a hard reset. (This might be depending on 
your hardware, on multi-core sytems this might only cause one of the cores to 
stall, so the system stays responsive in this case)


Expected behaviour: Trash cli should not stall the system when trashing one or 
more files thats filename has the max. length allowed by the file system.


Proposal for solution: _Replace_ the end of the filename in these cases rather 
than appending something, so the limit for file name length of the file system 
is observed by trash-cli.


trash-cli Version:

$ apt-cache policy trash-cli
trash-cli:
  Installiert:           0.17.1.14-5
  Installationskandidat: 0.17.1.14-5
  Versionstabelle:
 *** 0.17.1.14-5 500
        500 http://ftp.de.debian.org/debian bookworm/main amd64 Packages
        500 http://ftp.de.debian.org/debian bookworm/main i386 Packages
        100 /var/lib/dpkg/status



System: antiX 23.1 runit full 64 bit

$ uname -r
6.1.60-antix.1-amd64-smp

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

Reply via email to