Package: netcat-openbsd / 1.195-2

get-sev-by-name.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From: Aron Xu <aron@debian.org>
Date: Mon, 13 Feb 2012 14:45:08 +0800
Subject: get sev by name

---
 netcat.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--- a/netcat.c
+++ b/netcat.c
@@ -1653,11 +1653,16 @@ strtoport(char *portstr, int udp)
 void
 build_ports(char *p)
 {
+	struct servent *sv;
 	char *n;
 	int hi, lo, cp;
 	int x = 0;
 
-	if ((n = strchr(p, '-')) != NULL) {
+	sv = getservbyname(p, uflag ? "udp" : "tcp");
+	if (sv) {
+		if (asprintf(&portlist[0], "%d", ntohs(sv->s_port)) < 0)
+			err(1, "asprintf");
+	} else if ((n = strchr(p, '-')) != NULL) {
 		*n = '\0';
 		n++;