Bug#705223: netcat-openbsd: May send raw LF line endings even if the -C option is used
On Fri Apr 12 13:45:28 2013, happyaron...@gmail.com wrote: Hi, Can you try netcat-openbsd in Wheezy? It contains quite some fixes and there is something related to CRLF handling. Good suggestion. I experimented with it (netcat-openbsd_1.105-7_powerpc) this morning. It /may/ behave slightly differently -- hard to tell, since timing, ARP cache and so on is involved. But in the end, my complaint seems to apply to Wheezy too. Here's part of the strace for netcat-openbsd_1.105-7 being fed by the shell script. poll([{fd=3, events=POLLIN}, {fd=0, events=POLLIN}], 2, -1) = 1 ([{fd=0, revents=POLLIN}]) read(0, foobar\nfoobar\nfoobar\nfoobar\nfoob..., 2048) = 42 write(3, foobar\nfoobar\nfoobar\nfoobar\nfoob..., 41) = 41 write(3, \r\n, 2) = 2 poll([{fd=3, events=POLLIN}, {fd=0, events=POLLIN}], 2, -1) = 1 ([{fd=0, revents=POLLIN}]) read(0, foobar\n, 2048) = 7 write(3, foobar, 6) = 6 write(3, \r\n, 2) = 2 poll([{fd=3, events=POLLIN}, {fd=0, events=POLLIN}], 2, -1) = 1 ([{fd=0, revents=POLLIN}]) read(0, foobar\n, 2048) = 7 write(3, foobar, 6) = 6 write(3, \r\n, 2) = 2 poll([{fd=3, events=POLLIN}, {fd=0, events=POLLIN}], 2, -1) = 1 ([{fd=0, revents=POLLIN}]) read(0, foobar\n, 2048) = 7 write(3, foobar, 6) = 6 write(3, \r\n, 2) = 2 ... I.e. when nc has connected to the server and is ready to transmit, at least 42 bytes (6 lines) are already waiting on stdin. But nc assumes it's one line and just does one LF-CRLF translation. I suspect the same thing could happen later in the stream, except nc is fast enough in this scenario, and stdin is consumed line by line. BR, /Jorgen -- // Jörgen Grahn | mot du jour: Daughter of Pomira \X/ gr...@snipabacken.se | -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#705223: netcat-openbsd: May send raw LF line endings even if the -C option is used
Package: netcat-openbsd Version: 1.89-4 Severity: normal I was using this shell script to stress-test a TCP server I'm working on: #!/bin/bash action() { local delay=$1; shift local n=$1; shift while [ $((n--)) -gt 0 ] ; do echo foobar sleep $delay done } action $1 $2 | nc -C some-host some-port | wc The server takes CRLF-separated commands/requests, and I was puzzled when I found that it reported receiving fewer commands than I sent. After debugging the server for a while with no luck, I finally saw that the TCP stream from netcat contained some foobar\nfoobar\r\n patterns, e.g. immediately after connection. Whatever method the -C option uses to ensure translation of CR to CRLF, it's not foolproof. Maybe only slow manual input was considered. My workaround was to stop using -C, and to add CRLF explicitly using echo -ne foobar\r\n instead. BR, Jorgen -- System Information: Debian Release: 6.0.7 APT prefers stable APT policy: (500, 'stable') Architecture: powerpc (ppc) Kernel: Linux 3.4.10 Locale: LANG=sv_SE, LC_CTYPE=sv_SE (charmap=ISO-8859-1) Shell: /bin/sh linked to /bin/dash Versions of packages netcat-openbsd depends on: ii libc6 2.11.3-4 Embedded GNU C Library: Shared lib ii libglib2.0-0 2.24.2-1 The GLib library of C routines netcat-openbsd recommends no packages. netcat-openbsd suggests no packages. -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#705223: netcat-openbsd: May send raw LF line endings even if the -C option is used
Hi, Can you try netcat-openbsd in Wheezy? It contains quite some fixes and there is something related to CRLF handling. On Thu, Apr 11, 2013 at 9:37 PM, Jorgen Grahn grahn+deb...@snipabacken.se wrote: Package: netcat-openbsd Version: 1.89-4 Severity: normal I was using this shell script to stress-test a TCP server I'm working on: #!/bin/bash action() { local delay=$1; shift local n=$1; shift while [ $((n--)) -gt 0 ] ; do echo foobar sleep $delay done } action $1 $2 | nc -C some-host some-port | wc The server takes CRLF-separated commands/requests, and I was puzzled when I found that it reported receiving fewer commands than I sent. After debugging the server for a while with no luck, I finally saw that the TCP stream from netcat contained some foobar\nfoobar\r\n patterns, e.g. immediately after connection. Whatever method the -C option uses to ensure translation of CR to CRLF, it's not foolproof. Maybe only slow manual input was considered. My workaround was to stop using -C, and to add CRLF explicitly using echo -ne foobar\r\n instead. BR, Jorgen -- System Information: Debian Release: 6.0.7 APT prefers stable APT policy: (500, 'stable') Architecture: powerpc (ppc) Kernel: Linux 3.4.10 Locale: LANG=sv_SE, LC_CTYPE=sv_SE (charmap=ISO-8859-1) Shell: /bin/sh linked to /bin/dash Versions of packages netcat-openbsd depends on: ii libc6 2.11.3-4 Embedded GNU C Library: Shared lib ii libglib2.0-0 2.24.2-1 The GLib library of C routines netcat-openbsd recommends no packages. netcat-openbsd suggests no packages. -- no debconf information -- Regards, Aron Xu -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org