Bug 261819 - ports-mgmt/portfmt: portclippy will core dump for unknown command line options
Summary: ports-mgmt/portfmt: portclippy will core dump for unknown command line options
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Tobias Kortkamp
URL:
Keywords: crash
Depends on:
Blocks:
 
Reported: 2022-02-09 11:50 UTC by Martin Waschbüsch
Modified: 2022-02-09 12:45 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Waschbüsch 2022-02-09 11:50:40 UTC
portclippy knows only one command line option: --strict
However, the behavior when giving unknown options seems broken:

While unknown options with just one '-' produce output like this:

root@dev:~# portclippy -blub
portclippy: invalid option -- b
usage: portclippy [--strict] [Makefile]

If you give anything other than --strict using '--', it will just crash:

root@dev:~# portclippy --blub
Bus error (core dumped)


(Arguably, even in the first instance, it seems weird the message complains about the command line as if only one letter had been given.)

I have only tested this on 13.0-RELEASE on amd64.
Comment 1 Tobias Kortkamp freebsd_committer freebsd_triage 2022-02-09 12:45:42 UTC
Sigh, I forgot to terminate longopts. Thanks for the report. Fixed in
https://github.com/t6/portfmt/commit/8fe7439a7e783dacff988c50820877182327b98e

> (Arguably, even in the first instance, it seems weird the message complains about the command line as if only one letter had been given.)

That's just normal getopt_long() behavior. Compare with any other command
that uses it. For example:

$ ls -zap
ls: invalid option -- z