diff --git a/misc/ifstat.c b/misc/ifstat.c index 1be21703..ac3eff6b 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -992,12 +992,18 @@ int main(int argc, char *argv[]) && verify_forging(fd) == 0) { FILE *sfp = fdopen(fd, "r"); - load_raw_table(sfp); - if (hist_db && source_mismatch) { - fprintf(stderr, "ifstat: history is stale, ignoring it.\n"); - hist_db = NULL; + if (!sfp) { + fprintf(stderr, "ifstat: fdopen failed: %s\n", + strerror(errno)); + close(fd); + } else { + load_raw_table(sfp); + if (hist_db && source_mismatch) { + fprintf(stderr, "ifstat: history is stale, ignoring it.\n"); + hist_db = NULL; + } + fclose(sfp); } - fclose(sfp); } else { if (fd >= 0) close(fd); diff --git a/misc/nstat.c b/misc/nstat.c index 1212b1f2..a4dd405d 100644 --- a/misc/nstat.c +++ b/misc/nstat.c @@ -706,12 +706,18 @@ int main(int argc, char *argv[]) && verify_forging(fd) == 0) { FILE *sfp = fdopen(fd, "r"); - load_good_table(sfp); - if (hist_db && source_mismatch) { - fprintf(stderr, "nstat: history is stale, ignoring it.\n"); - hist_db = NULL; + if (!sfp) { + fprintf(stderr, "nstat: fdopen failed: %s\n", + strerror(errno)); + close(fd); + } else { + load_good_table(sfp); + if (hist_db && source_mismatch) { + fprintf(stderr, "nstat: history is stale, ignoring it.\n"); + hist_db = NULL; + } + fclose(sfp); } - fclose(sfp); } else { if (fd >= 0) close(fd);