Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for ncat --vsock -l <port> #2807

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions ncat/ncat_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,16 @@ int main(int argc, char *argv[])
break;
}
#endif
/* Support ncat -l <port>, but otherwise assume ncat <target> */
if (num_ports == 0 && o.listen) {
rc = strspn(argv[optind], "1234567890");
/* If the last arg is 5 or fewer digits, assume it's a port number */
if (argv[optind][rc] == '\0' && rc <= 5) {
o.portno = parseport(argv[optind], max_port, "port");
num_ports++;
break;
}
}
#if HAVE_LINUX_VM_SOCKETS_H
if (o.af == AF_VSOCK) {
long long_cid;
Expand All @@ -875,16 +885,6 @@ int main(int argc, char *argv[])
break;
}
#endif
/* Support ncat -l <port>, but otherwise assume ncat <target> */
if (num_ports == 0 && o.listen) {
rc = strspn(argv[optind], "1234567890");
/* If the last arg is 5 or fewer digits, assume it's a port number */
if (argv[optind][rc] == '\0' && rc <= 5) {
o.portno = parseport(argv[optind], max_port, "port");
num_ports++;
break;
}
}
o.target = argv[optind];
/* resolve hostname only if o.proxytype == NULL
* targetss contains data already and you don't want remove them
Expand Down