Bug 246919 - misc/mime-support: run-mailcap TempFile infinite loop
Summary: misc/mime-support: run-mailcap TempFile infinite loop
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Oliver Lehmann
Depends on:
Reported: 2020-06-01 20:09 UTC by G. Paul Ziemba
Modified: 2023-10-12 15:53 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (oliver)

patch for port misc/mime-support to improve tempfile name generation (1.35 KB, text/plain)
2020-06-01 20:09 UTC, G. Paul Ziemba
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description G. Paul Ziemba 2020-06-01 20:09:35 UTC
Created attachment 215143 [details]
patch for port misc/mime-support to improve tempfile name generation

When run-mailcap is called with a filename containing shell metacharacters, it attempts to symlink a temporary filename to the original file before calling a mime-type-specific program to process the file.

The subroutine TempFile, which is supposed to return the temporary filename, calls the linux-specific program "tempfile". On FreeBSD this call fails silently, causing TempFile to return an empty string, causing the calling loop to iterate endlessly.

The attached patch implements two changes:

1. Instead of calling the executable "tempfile", use perl's File::Temp which should work on all platforms

2. If the calling loop reaches fifty iterations, die
Comment 1 Oliver Lehmann freebsd_committer 2023-10-12 15:53:48 UTC
I've updated mime-support to 3.66.

It replaces tempfile with mktemp. While your solution is indeed better and more portable, mktemp should work as well. I'd like to try keeping the port as close as possible to the upstream version.

Please check if your initial problem is fixed with 3.66 (tempfile) and report back.

Sorry for the late answer on that topic.