1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Report system error message when fopen fails

This commit is contained in:
dmiller
2020-12-28 17:51:16 +00:00
parent f6fbb29481
commit ef2bafb09c
9 changed files with 13 additions and 13 deletions

View File

@@ -100,7 +100,7 @@ static void mac_prefix_init() {
fp = fopen(filename, "r");
if (!fp) {
error("Unable to open %s. Ethernet vendor correlation will not be performed ", filename);
gh_perror("Unable to open %s. Ethernet vendor correlation will not be performed ", filename);
return;
}
/* Record where this data file was found. */

View File

@@ -900,7 +900,7 @@ void parse_options(int argc, char **argv) {
} else {
o.inputfd = fopen(optarg, "r");
if (!o.inputfd) {
fatal("Failed to open input file %s for reading", optarg);
pfatal("Failed to open input file %s for reading", optarg);
}
}
} else if (strcmp(long_options[option_index].name, "iR") == 0) {
@@ -1070,7 +1070,7 @@ void parse_options(int argc, char **argv) {
} else {
o.inputfd = fopen(optarg, "r");
if (!o.inputfd) {
fatal("Failed to open input file %s for reading", optarg);
pfatal("Failed to open input file %s for reading", optarg);
}
}
break;
@@ -1368,7 +1368,7 @@ void parse_options(int argc, char **argv) {
if (o.verbose == 0) {
o.nmap_stdout = fopen(DEVNULL, "w");
if (!o.nmap_stdout)
fatal("Could not assign %s to stdout for writing", DEVNULL);
pfatal("Could not assign %s to stdout for writing", DEVNULL);
}
} else {
const char *p;
@@ -1683,7 +1683,7 @@ void apply_delayed_options() {
if (delayed_options.exclude_file) {
o.excludefd = fopen(delayed_options.exclude_file, "r");
if (!o.excludefd)
fatal("Failed to open exclude file %s for reading", delayed_options.exclude_file);
pfatal("Failed to open exclude file %s for reading", delayed_options.exclude_file);
free(delayed_options.exclude_file);
}
o.exclude_spec = delayed_options.exclude_spec;

View File

@@ -950,7 +950,7 @@ static void parse_resolvdotconf() {
fp = fopen("/etc/resolv.conf", "r");
if (fp == NULL) {
if (firstrun) error("mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers");
if (firstrun) gh_perror("mass_dns: warning: Unable to open /etc/resolv.conf. Try using --system-dns or specify valid servers with --dns-servers");
return;
}

View File

@@ -966,7 +966,7 @@ FingerPrintDB *parse_fingerprint_file(const char *fname) {
fp = fopen(fname, "r");
if (!fp)
fatal("Unable to open Nmap fingerprint file: %s", fname);
pfatal("Unable to open Nmap fingerprint file: %s", fname);
top:
while (fgets(line, sizeof(line), fp)) {

View File

@@ -1101,14 +1101,14 @@ int log_open(int logt, bool append, char *filename) {
o.logfd[i] = stdout;
o.nmap_stdout = fopen(DEVNULL, "w");
if (!o.nmap_stdout)
fatal("Could not assign %s to stdout for writing", DEVNULL);
pfatal("Could not assign %s to stdout for writing", DEVNULL);
} else {
if (append)
o.logfd[i] = fopen(filename, "a");
else
o.logfd[i] = fopen(filename, "w");
if (!o.logfd[i])
fatal("Failed to open %s output file %s for writing", logtypes[i],
pfatal("Failed to open %s output file %s for writing", logtypes[i],
filename);
}
return 1;

View File

@@ -297,7 +297,7 @@ int init_payloads(void) {
fp = fopen(filename, "r");
if (fp == NULL) {
fprintf(stderr, "Can't open %s for reading.\n", filename);
gh_perror("Can't open %s for reading.\n", filename);
return -1;
}
/* Record where this data file was found. */

View File

@@ -93,7 +93,7 @@ static int nmap_protocols_init() {
fp = fopen(filename, "r");
if (!fp) {
fatal("Unable to open %s for reading protocol information", filename);
pfatal("Unable to open %s for reading protocol information", filename);
}
/* Record where this data file was found. */
o.loaded_data_files["nmap-protocols"] = filename;

View File

@@ -1288,7 +1288,7 @@ void parse_nmap_service_probe_file(AllProbes *AP, char *filename) {
// We better start by opening the file
fp = fopen(filename, "r");
if (!fp)
fatal("Failed to open nmap-service-probes file %s for reading", filename);
pfatal("Failed to open nmap-service-probes file %s for reading", filename);
while(fgets(line, sizeof(line), fp)) {
lineno++;

View File

@@ -158,7 +158,7 @@ static int nmap_services_init() {
fp = fopen(filename, "r");
if (!fp) {
fatal("Unable to open %s for reading service information", filename);
pfatal("Unable to open %s for reading service information", filename);
}
/* Record where this data file was found. */
o.loaded_data_files["nmap-services"] = filename;