From 58418396a8f8b97b02d23bdcf63bbfc041aee832 Mon Sep 17 00:00:00 2001 From: henri Date: Mon, 29 Oct 2012 10:22:32 +0000 Subject: [PATCH] Make nping and ncat fail (the way nmap does) when invalid nsock engines are supplied. --- ncat/ncat_main.c | 3 ++- nping/ArgParser.cc | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ncat/ncat_main.c b/ncat/ncat_main.c index 33f7577eb..bd55248da 100644 --- a/ncat/ncat_main.c +++ b/ncat/ncat_main.c @@ -414,7 +414,8 @@ int main(int argc, char *argv[]) bye("You can't specify more than one --proxy-auth."); o.proxy_auth = Strdup(optarg); } else if (strcmp(long_options[option_index].name, "nsock-engine") == 0) { - nsock_set_default_engine(optarg); + if (nsock_set_default_engine(optarg) < 0) + bye("Unknown or non-available engine: %s.", optarg); } else if (strcmp(long_options[option_index].name, "broker") == 0) { o.broker = 1; /* --broker implies --listen. */ diff --git a/nping/ArgParser.cc b/nping/ArgParser.cc index ea8035032..a6df2dab1 100644 --- a/nping/ArgParser.cc +++ b/nping/ArgParser.cc @@ -956,8 +956,8 @@ char errstr[256]; if( o.issetDisablePacketCapture() && o.disablePacketCapture()==true ) outError(QT_2, "Warning: There is no point on specifying a BPF filter if you disable packet capture. BPF filter will be ignored."); } else if (optcmp(long_options[option_index].name, "nsock-engine") == 0){ - nsock_set_default_engine(optarg); - + if (nsock_set_default_engine(optarg) < 0) + outFatal(QT_3, "Unknown or non-available engine: %s", optarg); /* Output Options */ } else if (optcmp(long_options[option_index].name, "quiet") == 0 ){ o.setVerbosity(-4);