Skip to content

Commit

Permalink
smartdns: Fixe coredump issue caused by running smartdns --help
Browse files Browse the repository at this point in the history
  • Loading branch information
pymumu committed Sep 14, 2023
1 parent f7ede1b commit 28139d2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/smartdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,8 @@ int main(int argc, char *argv[])
sigset_t empty_sigblock;
struct stat sb;

static struct option long_options[] = {{"cache-print", required_argument, 0, 256}};
static struct option long_options[] = {
{"cache-print", required_argument, 0, 256}, {"help", no_argument, 0, 'h'}, {NULL, 0, 0, 0}};

safe_strncpy(config_file, SMARTDNS_CONF_FILE, MAX_LINE_LEN);

Expand Down Expand Up @@ -811,9 +812,13 @@ int main(int argc, char *argv[])
#endif
case 'h':
_help();
return 1;
return 0;
case 256:
return dns_cache_print(optarg);
break;
default:
fprintf(stderr, "unknown option, please run %s -h for help.\n", argv[0]);
return 1;
}
}

Expand Down

0 comments on commit 28139d2

Please sign in to comment.