Sophie

Sophie

distrib > Mageia > 3 > i586 > media > core-release-src > by-pkgid > 14d66bf8988361107689f9ce2e9a8abf > files > 3

netcat-openbsd-1.89-5.mga3.src.rpm

Index: netcat-openbsd-1.89/netcat.c
===================================================================
--- netcat-openbsd-1.89.orig/netcat.c	2008-01-22 20:39:46.000000000 -0500
+++ netcat-openbsd-1.89/netcat.c	2008-01-22 20:43:36.000000000 -0500
@@ -819,11 +819,18 @@
 void
 build_ports(char *p)
 {
+	struct servent *sv;
 	char *n, *endp;
 	int hi, lo, cp;
 	int x = 0;
 
-	if ((n = strchr(p, '-')) != NULL) {
+	sv = getservbyname(p, uflag ? "udp" : "tcp");
+	if (sv) {
+		portlist[0] = calloc(1, PORT_MAX_LEN);
+		if (portlist[0] == NULL)
+			err(1, NULL);
+		snprintf(portlist[0], PORT_MAX_LEN, "%d", ntohs(sv->s_port));
+	} else if ((n = strchr(p, '-')) != NULL) {
 		if (lflag)
 			errx(1, "Cannot use -l with multiple ports!");