Page MenuHomeFreeBSD

netcat: add --crlf to convert LF into CRLF
ClosedPublic

Authored by gahr on Aug 17 2023, 11:53 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 24, 4:20 PM
Unknown Object (File)
Mar 31 2024, 5:10 PM
Unknown Object (File)
Mar 31 2024, 5:09 PM
Unknown Object (File)
Dec 26 2023, 7:27 AM
Unknown Object (File)
Dec 25 2023, 5:17 PM
Unknown Object (File)
Dec 24 2023, 8:41 PM
Unknown Object (File)
Dec 23 2023, 12:49 AM
Unknown Object (File)
Dec 21 2023, 8:24 PM
Subscribers

Details

Summary

This adds the --crlf option to netcat, which triggers translation of \n characters into \r\n sequences in the input -> network direction.
The Linux version of nc also supports this functionality with --crlf and -C. The OpenBSD version uses -C to specify client certificates. Our version is too old and doesn't have it, but I avoided adding -C anyway to ease future syncs with upstream.

Test Plan

An interactive session with nginx suffices to test that --crlf allows you to trigger an HTTP Response.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

gahr requested review of this revision.Aug 17 2023, 11:53 AM
gahr edited the test plan for this revision. (Show Details)
contrib/netcat/netcat.c
174

These should be alphabetically sorted.

986

Suppose there is some data after a LF. Now, if --crlf is specified, we do not write it right away. It looks like we'll poll() and immediately try again, so this is not a problem. Am I understanding correctly?

1059
1062

If the input starts with a LF, we won't add the CR, is that right?

contrib/netcat/netcat.c
986

Yes

1062

Yes, we do add the CR in case the line starts with a LF.

gahr marked 2 inline comments as done.Aug 17 2023, 3:43 PM

Updating D41489: netcat: add --crlf to convert LF into CRLF

markj added inline comments.
contrib/netcat/netcat.c
1062

Sorry, I had misread.

This revision is now accepted and ready to land.Aug 21 2023, 12:50 PM

LGTM (note that since this is OS independent it's probably worth a try to upstream it and avoid divergence from OpenBSD)

LGTM (note that since this is OS independent it's probably worth a try to upstream it and avoid divergence from OpenBSD)

Good idea, I'll try that!

This revision was automatically updated to reflect the committed changes.