Public bug reported:

I have a zip file where the first enclosed file is PDF. For a reason (I
strictly prefer okular over evince and was lazy to find another place to
set the priority), I changed the mc extension file (mc.ext) entry to the
following:

```
type/^PDF
        Open=okular %f & disown
```

Unexpectedly, this caused misopening of some zip files. Checking what is
happening by strace showed that mc calls `file` with arguments to detect
the enclosed contents:

1368162 19:40:43.017932 execve("/usr/bin/file", ["file", "-z", "-S",
"-L", "/home/netch/Downloads/sql_12.zip"], 0x6017f1d3d398 /* 68 vars */
<unfinished ...>

and this file helper returns:

1368162 19:40:43.040724 write(1, "PDF document, version 1.3, 90 pages
(Zip archive data, at least v2.0 to extract, compression
method=deflate)\n", 109) = 109

The rule in the extension file detects, according to "^PDF", this is PDF
and runs `okular` instead of `ark` for this file. Okular deliberately
rejects opening zip.

With the default extension file contents:

```
    Open=/usr/lib/mc/ext.d/doc.sh open pdf
```

the bug still has place but is masked because passing through `doc.sh`
and then `xdg-open` rechecks the file type using `file` (technically,
with `kioslave5`) without `-z` that allows proper detection.

So using simple `file/` rules in mc extension file is incompatible with
using `file -z` for deeper analysis (if this deeper analysis has sense
in general).

Iʼm uncertain for security impact but it could have taken place in a
more complicated scenario.

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: mc 3:4.8.27-1
ProcVersionSignature: Ubuntu 6.8.0-52.53~22.04.1-generic 6.8.12
Uname: Linux 6.8.0-52-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.6
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: KDE
Date: Thu Feb  6 19:49:22 2025
InstallationDate: Installed on 2024-11-26 (71 days ago)
InstallationMedia: Kubuntu 22.04.3 LTS "Jammy Jellyfish" - Release amd64 
(20230807.1)
SourcePackage: mc
UpgradeStatus: No upgrade log present (probably fresh install)

** Affects: mc (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug jammy

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2097560

Title:
  mc misdetects zip due to `file` arguments

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/mc/+bug/2097560/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to