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)
Mon, Oct 28, 7:20 PM
Unknown Object (File)
Mon, Oct 21, 12:54 PM
Unknown Object (File)
Mon, Oct 21, 12:54 PM
Unknown Object (File)
Mon, Oct 21, 12:53 PM
Unknown Object (File)
Mon, Oct 21, 12:53 PM
Unknown Object (File)
Mon, Oct 21, 12:53 PM
Unknown Object (File)
Mon, Oct 21, 12:42 PM
Unknown Object (File)
Thu, Oct 17, 2:33 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.