diff --git a/srcpkgs/pwnat/patches/fix_argument_parsing.diff b/srcpkgs/pwnat/patches/fix_argument_parsing.diff new file mode 100644 index 00000000000..316441e6126 --- /dev/null +++ b/srcpkgs/pwnat/patches/fix_argument_parsing.diff @@ -0,0 +1,89 @@ +From ef844e18aad75929bad415bbc633a760890501e8 Mon Sep 17 00:00:00 2001 +From: timdiels +Date: Mon, 30 Sep 2013 18:27:13 +0200 +Subject: [PATCH] Fixed bug in client argument parsing + +e.g. pwnat -c 44444 a b 22 +would recognise "b" as proxy port, and eventually crash with a segfault +--- + udpclient.c | 45 ++++++++++++++++++++++++++++----------------- + 1 file changed, 28 insertions(+), 17 deletions(-) + +diff --git udpclient.c udpclient.c +index a95ac50..0d23c0d 100644 +--- udpclient.c ++++ udpclient.c +@@ -60,7 +60,20 @@ static void disconnect_and_remove_client(uint16_t id, list_t *clients, + fd_set *fds); + static void signal_handler(int sig); + +-int udpclient(int argc, char *argv[]) ++bool isnumber(const char* str) { ++ if (!str) { ++ return false; ++ } ++ ++ char* end; ++ strtol(str, &end, 10); ++ return *end == '\0'; ++} ++ ++/* ++ * argv: [local ip] [proxy port] ++ */ ++int udpclient(int argc, char* argv[]) + { + char *lhost, *lport, *phost, *pport, *rhost, *rport; + list_t *clients; +@@ -72,7 +85,7 @@ int udpclient(int argc, char *argv[]) + socket_t *udp_sock = NULL; + char data[MSG_MAX_LEN]; + char addrstr[ADDRSTRLEN]; +- char pport_s[6]; ++ char pport_s[6] = "2222"; + + struct timeval curr_time; + struct timeval check_time; +@@ -89,29 +102,27 @@ int udpclient(int argc, char *argv[]) + int ret; + int i; + +- int icmp_sock = 0; ++ int icmp_sock = 0; + int timeexc = 0; + +- struct sockaddr_in src, dest, rsrc; +- struct hostent *hp; +- uint32_t timeexc_ip; ++ struct sockaddr_in src, dest, rsrc; ++ struct hostent *hp; ++ uint32_t timeexc_ip; + + signal(SIGINT, &signal_handler); + ++ // Parse arguments + i = 0; +- if (index(argv[i], 58) || index(argv[i], 46)) +- lhost = argv[i++]; +- else +- lhost = NULL; ++ if (!isnumber(argv[i])) ++ lhost = argv[i++]; ++ else ++ lhost = NULL; + lport = argv[i++]; + phost = argv[i++]; +- if (index(argv[i], 58) || index(argv[i], 46)) +- { +- snprintf(pport_s, 5, "2222"); +- pport = pport_s; +- } +- else +- pport = argv[i++]; ++ if (isnumber(argv[i])) ++ pport = argv[i++]; ++ else ++ pport = pport_s; + rhost = argv[i++]; + rport = argv[i++]; + diff --git a/srcpkgs/pwnat/template b/srcpkgs/pwnat/template new file mode 100644 index 00000000000..f30924c3f88 --- /dev/null +++ b/srcpkgs/pwnat/template @@ -0,0 +1,18 @@ +# Template file for 'pwnat' +pkgname=pwnat +version=0.3 +# the git-hash of v0.3 as it isn't tagged +_githash=572fcfb76a1b4b46faaa6b36817a39671b6f3c7e +revision=1 +homepage="http://samy.pl/pwnat/" +distfiles="https://github.com/samyk/pwnat/archive/${_githash}.tar.gz" +short_desc="serverless NAT to NAT hole punching" +maintainer="Enno Boland " +license="GPLv3" +checksum=365da981ba1a39d7e3c8427fbcd9e7fcd3dd16cd30ae7e3b0aca50511fd8e1b1 +wrksrc="${pkgname}-${_githash}" +build_style=gnu-makefile + +do_install() { + vbin pwnat +}