mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 06:40:48 +00:00
Don't fatal() in nsock_set_default_engine()
Return negative value instead. Moved the fatal() statement to nmap.cc
This commit is contained in:
parent
5aaf80a0b9
commit
e76d41fa04
3 changed files with 13 additions and 10 deletions
3
nmap.cc
3
nmap.cc
|
|
@ -802,7 +802,8 @@ void parse_options(int argc, char **argv) {
|
|||
o.randomize_hosts = 1;
|
||||
o.ping_group_sz = PING_GROUP_SZ * 4;
|
||||
} else if (optcmp(long_options[option_index].name, "nsock-engine") == 0) {
|
||||
nsock_set_default_engine(optarg);
|
||||
if (nsock_set_default_engine(optarg) < 0)
|
||||
fatal("Unknown or non-available engine: %s", optarg);
|
||||
} else if (optcmp(long_options[option_index].name, "osscan-limit") == 0) {
|
||||
o.osscan_limit = 1;
|
||||
} else if (optcmp(long_options[option_index].name, "osscan-guess") == 0
|
||||
|
|
|
|||
|
|
@ -201,8 +201,10 @@ nsock_ssl_ctx nsp_ssl_init_max_speed(nsock_pool ms_pool);
|
|||
* strup()'ed by the library. No validity check is performed by this function,
|
||||
* beware nsp_new() will fatal() if an invalid/unavailable engine name was
|
||||
* supplied before.
|
||||
* Pass NULL to reset to default (use most efficient engine available). */
|
||||
void nsock_set_default_engine(char *engine);
|
||||
* Pass NULL to reset to default (use most efficient engine available).
|
||||
*
|
||||
* Function returns 0 on success and -1 on error. */
|
||||
int nsock_set_default_engine(char *engine);
|
||||
|
||||
/* Get a comma-separated list of available engines. */
|
||||
const char *nsock_list_engines(void);
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ struct io_engine *get_io_engine(void) {
|
|||
return engine;
|
||||
}
|
||||
|
||||
void nsock_set_default_engine(char *engine) {
|
||||
int nsock_set_default_engine(char *engine) {
|
||||
if (engine_hint)
|
||||
free(engine_hint);
|
||||
|
||||
|
|
@ -117,15 +117,15 @@ void nsock_set_default_engine(char *engine) {
|
|||
for (i = 0; available_engines[i] != NULL; i++) {
|
||||
if (strcmp(engine, available_engines[i]->name) == 0) {
|
||||
engine_hint = strdup(engine);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
fatal("Unknown or non-available IO engine: %s\n", engine);
|
||||
} else {
|
||||
/* having engine = NULL is fine. This is actually the
|
||||
* way to tell nsock to use the default engine again. */
|
||||
engine_hint = NULL;
|
||||
return -1;
|
||||
}
|
||||
/* having engine = NULL is fine. This is actually the
|
||||
* way to tell nsock to use the default engine again. */
|
||||
engine_hint = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *nsock_list_engines(void) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue