source: npl/overig/netcat_openbsd/patches/0003-get-sev-by-name.patch @ 7c410f9

Last change on this file since 7c410f9 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: 881 bytes
RevLine 
[c5c522c]1From: Aron Xu <aron@debian.org>
2Date: Mon, 13 Feb 2012 14:45:08 +0800
3Subject: get sev by name
4
5---
6 netcat.c |    9 ++++++++-
7 1 file changed, 8 insertions(+), 1 deletion(-)
8
9diff --git a/netcat.c b/netcat.c
10index f3cc8c1..d912544 100644
11--- a/netcat.c
12+++ b/netcat.c
13@@ -949,12 +949,19 @@ atelnet(int nfd, unsigned char *buf, unsigned int size)
14 void
15 build_ports(char *p)
16 {
17+        struct servent *sv;
18        const char *errstr;
19        char *n;
20        int hi, lo, cp;
21        int x = 0;
22 
23-       if ((n = strchr(p, '-')) != NULL) {
24+        sv = getservbyname(p, uflag ? "udp" : "tcp");
25+        if (sv) {
26+                portlist[0] = calloc(1, PORT_MAX_LEN);
27+                if (portlist[0] == NULL)
28+                        err(1, NULL);
29+                snprintf(portlist[0], PORT_MAX_LEN, "%d", ntohs(sv->s_port));
30+        } else if ((n = strchr(p, '-')) != NULL) {
31                *n = '\0';
32                n++;
33 
34--
Note: See TracBrowser for help on using the repository browser.