Trim CR-LF when parsing LINE from file#95
Open
Ex-Ark wants to merge 1 commit intoMatty9191:masterfrom
Open
Conversation
Using a CR-LF encoded file and running `ssl-cert-check -f filename` currently results in invalid PORT parsing and later failing `openssl` command as half the command is truncated due to endline in the middle of the string. (`$2` has CR-LF char)
The only visible error is `ERROR: The file named /var/tmp/cert.XXXXX is unreadable or doesn't exist` but after some debuging I found out that `"${OPENSSL}" s_client $OPTIONS 2> "${ERROR_TMP}" 1> "${CERT_TMP}"` resulted in empty tmp file due to `$OPTIONS` being truncated .
We can make the script compatible with CR-LF input files by removing `\r` from the parsed line.
Should not be a breaking change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current issue
Using a CR-LF encoded file and running
ssl-cert-check -f filenamecurrently results in invalid PORT parsing and later failingopensslcommandThe currently visible error is
but after some debuging I found out that
"${OPENSSL}" s_client $OPTIONS 2> "${ERROR_TMP}" 1> "${CERT_TMP}"fails withThis is due to
$OPTIONSbeing truncated as the$2variable inside it has a CR-LF char, so the command passed to openssl has invalid syntax.Here's what
$OPTIONSlook like with CR-LF input file :"-servername host.domain.local"the first half of the command is truncated (
"-connect ${1}:${2}")Fix
We can make the script compatible with CR-LF input files by removing
\rfrom the parsed line.some issues mention this error, I guess they were running the command against CR-LF input file.
Should not be a breaking change, I tried with CR-LF and LF encoded file, both works with this fix.