forked from pool/netcat-openbsd
OBS-URL: https://build.opensuse.org/package/show/network:utilities/netcat-openbsd?expand=0&rev=29
31 lines
763 B
Diff
31 lines
763 B
Diff
From: Aron Xu <aron@debian.org>
|
|
Date: Mon, 13 Feb 2012 14:45:08 +0800
|
|
Subject: Add ability to specify destination ports by name
|
|
|
|
---
|
|
netcat.c | 7 ++++++-
|
|
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/netcat.c b/netcat.c
|
|
index 461e2bd..2dc1abd 100644
|
|
--- a/netcat.c
|
|
+++ b/netcat.c
|
|
@@ -1700,11 +1700,16 @@ strtoport(char *portstr, int udp)
|
|
void
|
|
build_ports(char *p)
|
|
{
|
|
+ struct servent *sv;
|
|
char *n;
|
|
int hi, lo, cp;
|
|
int x = 0;
|
|
|
|
- if (isdigit((unsigned char)*p) && (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 (isdigit((unsigned char)*p) && (n = strchr(p, '-')) != NULL) {
|
|
*n = '\0';
|
|
n++;
|
|
|