source: npl/overig/netcat_openbsd/patches/0005-send-crlf.patch @ 30f002a

Last change on this file since 30f002a was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 3.0 KB
  • nc.1

    From: Aron Xu <aron@debian.org>
    Date: Mon, 13 Feb 2012 14:57:45 +0800
    Subject: send crlf
    
    ---
     nc.1     |    6 ++++--
     netcat.c |   21 +++++++++++++++++----
     2 files changed, 21 insertions(+), 6 deletions(-)
    
    diff --git a/nc.1 b/nc.1
    index b7014a2..af44976 100644
    a b  
    3434.Sh SYNOPSIS
    3535.Nm nc
    3636.Bk -words
    37 .Op Fl 46DdhklnrStUuvz
     37.Op Fl 46CDdhklnrStUuvz
    3838.Op Fl I Ar length
    3939.Op Fl i Ar interval
    4040.Op Fl O Ar length
    to use IPv4 addresses only. 
    9898Forces
    9999.Nm
    100100to use IPv6 addresses only.
     101.It Fl C
     102Send CRLF as line-ending.
    101103.It Fl D
    102104Enable debugging on the socket.
    103105.It Fl d
    More complicated examples can be built up when the user knows the format 
    355357of requests required by the server.
    356358As another example, an email may be submitted to an SMTP server using:
    357359.Bd -literal -offset indent
    358 $ nc localhost 25 \*(Lt\*(Lt EOF
     360$ nc [\-C] localhost 25 \*(Lt\*(Lt EOF
    359361HELO host.example.com
    360362MAIL FROM:\*(Ltuser@host.example.com\*(Gt
    361363RCPT TO:\*(Ltuser2@host.example.com\*(Gt
  • netcat.c

    diff --git a/netcat.c b/netcat.c
    index fdaca44..4f4d2bf 100644
    a b  
    111111#define CONNECTION_TIMEOUT 2
    112112
    113113/* Command Line Options */
     114int     Cflag = 0;                              /* CRLF line-ending */
    114115int     dflag;                                  /* detached, no stdin */
    115116unsigned int iflag;                             /* Interval Flag */
    116117int     jflag;                                  /* use jumbo frames if we can */
    main(int argc, char *argv[]) 
    180181        sv = NULL;
    181182
    182183        while ((ch = getopt(argc, argv,
    183             "46DdhI:i:jklnO:P:p:rSs:tT:UuV:vw:X:x:z")) != -1) {
     184            "46CDdhI:i:jklnO:P:p:rSs:tT:UuV:vw:X:x:z")) != -1) {
    184185                switch (ch) {
    185186                case '4':
    186187                        family = AF_INET;
    main(int argc, char *argv[]) 
    309310                        if (Tflag < 0 || Tflag > 255 || errstr || errno)
    310311                                errx(1, "illegal tos value %s", optarg);
    311312                        break;
     313                case 'C':
     314                        Cflag = 1;
     315                        break;
    312316                default:
    313317                        usage(1);
    314318                }
    readwrite(int nfd) 
    906910                        else if (n == 0) {
    907911                                goto shutdown_wr;
    908912                        } else {
    909                                 if (atomicio(vwrite, nfd, buf, n) != n)
    910                                         return;
     913                                if ((Cflag) && (buf[n-1]=='\n')) {
     914                                        if (atomicio(vwrite, nfd, buf, n-1) != (n-1))
     915                                                return;
     916                                        if (atomicio(vwrite, nfd, "\r\n", 2) != 2)
     917                                                return;
     918                                }
     919                                else {
     920                                        if (atomicio(vwrite, nfd, buf, n) != n)
     921                                                return;
     922                                }
    911923                        }
    912924                        }
    913925                        else if (pfd[1].revents & POLLHUP) {
    help(void) 
    11391151        fprintf(stderr, "\tCommand Summary:\n\
    11401152        \t-4            Use IPv4\n\
    11411153        \t-6            Use IPv6\n\
     1154        \t-C            Send CRLF as line-ending\n\
    11421155        \t-D            Enable the debug socket option\n\
    11431156        \t-d            Detach from stdin\n\
    11441157        \t-h            This help text\n\
    void 
    11721185usage(int ret)
    11731186{
    11741187        fprintf(stderr,
    1175             "usage: nc [-46DdhjklnrStUuvz] [-I length] [-i interval] [-O length]\n"
     1188            "usage: nc [-46CDdhjklnrStUuvz] [-I length] [-i interval] [-O length]\n"
    11761189            "\t  [-P proxy_username] [-p source_port] [-s source] [-T toskeyword]\n"
    11771190            "\t  [-V rtable] [-w timeout] [-X proxy_protocol]\n"
    11781191            "\t  [-x proxy_address[:port]] [destination] [port]\n");
Note: See TracBrowser for help on using the repository browser.