Bug 719386 - nc -C -u results in two separate datagrams for any message sent
Summary: nc -C -u results in two separate datagrams for any message sent
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: nc
Version: 15
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Petr Šabata
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-07-06 16:35 UTC by Jaroslav Franek
Modified: 2011-07-18 22:43 UTC (History)
2 users (show)

Fixed In Version: nc-1.100-3.fc15
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-07-18 22:43:02 UTC
Type: ---


Attachments (Terms of Use)
Source code patch (537 bytes, patch)
2011-07-06 16:35 UTC, Jaroslav Franek
jarin.franek: review?
Details | Diff
Wireshark capture of original TCP behavior (1.02 KB, application/octet-stream)
2011-07-06 16:37 UTC, Jaroslav Franek
no flags Details
Wireshark capture of original UDP behavior (297 bytes, application/octet-stream)
2011-07-06 16:38 UTC, Jaroslav Franek
no flags Details
Wireshark capture of fixed TCP behavior (884 bytes, application/octet-stream)
2011-07-06 16:39 UTC, Jaroslav Franek
no flags Details
Wireshark capture of fixed UDP behavior (164 bytes, application/octet-stream)
2011-07-06 16:40 UTC, Jaroslav Franek
no flags Details

Description Jaroslav Franek 2011-07-06 16:35:36 UTC
Created attachment 511528 [details]
Source code patch

Description of problem:
When using -C option with nc, the program makes two writes into socket:
1) the message itself
2) the CRLF bytes "\r\n"
For TCP it results in aditional message of 2 bytes + ack, but since TCP is a stream, the client or server may not notice.
For UDP it results in two separate datagrams and this is bad as UDP does not guarantee delivery nor order of the datagrams. Even the client/server is got by surprise as it expected a single datagram containing a valid protocol message.

Version-Release number of selected component (if applicable):
nc-1.100-2.fc15.i686

How reproducible:
(TCP) nc -C 127.0.0.1 <port>
(UDP) nc -C -u 127.0.0.1 <port>

Steps to Reproduce:
see above
  
Actual results:
see Wireshark dumps attached (nc_tcp_orig.cap, nc_udp_orig.cap)

Expected results:
using the supplied patch, CRLF is sent in the same message (one write to the socket), see Wireshark dumps attached (nc_tcp_fixed.cap, nc_udp_fixed.cap)

Additional info:
Patch against nc-1.100-2.fc15 provided for review.

Comment 1 Jaroslav Franek 2011-07-06 16:37:43 UTC
Created attachment 511531 [details]
Wireshark capture of original TCP behavior

Comment 2 Jaroslav Franek 2011-07-06 16:38:42 UTC
Created attachment 511532 [details]
Wireshark capture of original UDP behavior

Comment 3 Jaroslav Franek 2011-07-06 16:39:24 UTC
Created attachment 511533 [details]
Wireshark capture of fixed TCP behavior

Comment 4 Jaroslav Franek 2011-07-06 16:40:10 UTC
Created attachment 511534 [details]
Wireshark capture of fixed UDP behavior

Comment 5 Petr Šabata 2011-07-07 15:20:44 UTC
Thanks, Jaroslav.  The patch looks good to me.

Comment 6 Fedora Update System 2011-07-07 15:32:01 UTC
nc-1.100-3.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/nc-1.100-3.fc15

Comment 7 Fedora Update System 2011-07-08 17:58:07 UTC
Package nc-1.100-3.fc15:
* should fix your issue,
* was pushed to the Fedora 15 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing nc-1.100-3.fc15'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/nc-1.100-3.fc15
then log in and leave karma (feedback).

Comment 8 Fedora Update System 2011-07-18 22:42:56 UTC
nc-1.100-3.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.