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)
Tue, Oct 1, 5:29 AM
Unknown Object (File)
Mon, Sep 30, 11:28 PM
Unknown Object (File)
Fri, Sep 27, 11:09 AM
Unknown Object (File)
Fri, Sep 27, 11:09 AM
Unknown Object (File)
Sun, Sep 22, 4:25 AM
Unknown Object (File)
Fri, Sep 20, 11:32 PM
Unknown Object (File)
Wed, Sep 18, 2:21 AM
Unknown Object (File)
Tue, Sep 17, 8:05 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
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 53155
Build 50046: arc lint + arc unit

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.