Bug 246919

Summary: misc/mime-support: run-mailcap TempFile infinite loop
Product: Ports & Packages Reporter: G. Paul Ziemba <p-fbsd-bugs>
Component: Individual Port(s)Assignee: Oliver Lehmann <oliver>
Status: New ---    
Severity: Affects Only Me Flags: bugzilla: maintainer-feedback? (oliver)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch for port misc/mime-support to improve tempfile name generation none

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