Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 98f91f0622574a10d6f7dc80b385ac0a > files > 3

nc-1.100-3.fc15.src.rpm

--- nc/netcat.c	2011-03-08 15:31:25.910563002 +0100
+++ nc/netcat.c.new	2011-03-08 15:37:48.252563204 +0100
@@ -86,6 +86,7 @@
 int	Oflag;					/* TCP send buffer size */
 int	Sflag;					/* TCP MD5 signature option */
 int	Tflag = -1;				/* IP Type of Service */
+int Cflag = 0;				/* CRLF line-ending */
 
 int timeout = -1;
 int family = AF_UNSPEC;
@@ -130,7 +131,7 @@
 	sv = NULL;
 
 	while ((ch = getopt(argc, argv,
-	    "46DdhI:i:klnO:P:p:rSs:tT:Uuvw:X:x:z")) != -1) {
+	    "46CDdhI:i:klnO:P:p:rSs:tT:Uuvw:X:x:z")) != -1) {
 		switch (ch) {
 		case '4':
 			family = AF_INET;
@@ -227,6 +228,9 @@
 		case 'T':
 			Tflag = parse_iptos(optarg);
 			break;
+		case 'C':
+			Cflag = 1;
+			break;
 		default:
 			usage(1);
 		}
@@ -696,8 +700,15 @@
 				else if (n == 0) {
 					goto shutdown_wr;
 				} else {
-					if (atomicio(vwrite, nfd, buf, n) != n)
-						return;
+					if (Cflag && (buf[n-1] == '\n')) {
+						buf[n-1] = '\r';
+						buf[n]   = '\n';
+						if (atomicio(vwrite, nfd, buf, n+1) != n+1)
+							return;
+					} else {
+						if (atomicio(vwrite, nfd, buf, n) != n)
+							return;
+					}
 				}
 			}
 			else if (pfd[1].revents & POLLHUP) {
@@ -902,6 +913,7 @@
 	\t-S		Enable the TCP MD5 signature option\n\
 	\t-s addr\t	Local source address\n\
 	\t-T ToS\t	Set IP Type of Service\n\
+	\t-C		Send CRLF as line-ending\n\
 	\t-t		Answer TELNET negotiation\n\
 	\t-U		Use UNIX domain socket\n\
 	\t-u		UDP mode\n\
@@ -919,7 +931,7 @@
 usage(int ret)
 {
 	fprintf(stderr,
-	    "usage: nc [-46DdhklnrStUuvz] [-I length] [-i interval] [-O length]\n"
+	    "usage: nc [-46CDdhklnrStUuvz] [-I length] [-i interval] [-O length]\n"
 	    "\t  [-P proxy_username] [-p source_port] [-s source] [-T ToS]\n"
 	    "\t  [-V rtable] [-w timeout] [-X proxy_protocol]\n"
 	    "\t  [-x proxy_address[:port]] [destination] [port]\n");
--- nc/nc.1	2011-01-09 23:16:46.000000000 +0100
+++ nc/nc.1.new	2011-03-08 15:39:03.834566792 +0100
@@ -34,7 +34,7 @@
 .Sh SYNOPSIS
 .Nm nc
 .Bk -words
-.Op Fl 46DdhklnrStUuvz
+.Op Fl 46CDdhklnrStUuvz
 .Op Fl I Ar length
 .Op Fl i Ar interval
 .Op Fl O Ar length
@@ -98,6 +98,8 @@
 Forces
 .Nm
 to use IPv6 addresses only.
+.It Fl C
+Send CRLF as line-ending.
 .It Fl D
 Enable debugging on the socket.
 .It Fl d