Skip to content

Fix --mx host:port parsing and incorrect no-MX message (#2986)#3049

Merged
drwetter merged 1 commit into
testssl:3.3devfrom
potato-20:fix-mx-host-port-2986
Jun 8, 2026
Merged

Fix --mx host:port parsing and incorrect no-MX message (#2986)#3049
drwetter merged 1 commit into
testssl:3.3devfrom
potato-20:fix-mx-host-port-2986

Conversation

@potato-20

Copy link
Copy Markdown
Contributor

Fixes #2986.

--mx <host>:<port> confused the parser: --mx sets PORT=25 unconditionally, and the trailing :port on the domain was never stripped before the MX DNS lookup — so host -t MX example.com:25 returned nothing, and the failure branch then printed $1 (the run date) instead of the host, e.g. 20260606-1200 has no MX records(s).

This:

  • strips a trailing :<port> off the domain before the get_mx_record lookup (bash parameter expansion, no extra fork) and uses it as the port under test;
  • corrects the no-MX message to print the actual $domain and MX record(s) (typo).

Tested against multiple hosts with and without an appended :port (e.g. --mx google.com:25 now resolves the MX and proceeds on port 25); plain --mx example.com behaviour is unchanged. shellcheck -x -P utils --severity=error clean and bash -n clean on the change; five-space/no-tabs convention followed.

When a port was appended to the domain (e.g. "--mx example.com:25"), the suffix was passed straight into the MX DNS lookup, so no MX records were found. Strip a trailing :port off the domain before the lookup and use it as the port to test. Also fix the no-MX message, which printed $1 (the run date) instead of the domain, plus a "records(s)" typo.
@potato-20 potato-20 mentioned this pull request Jun 6, 2026
@drwetter drwetter merged commit 8f58881 into testssl:3.3dev Jun 8, 2026
4 of 5 checks passed
@drwetter

drwetter commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

confusing output

2 participants