From: David Bauer Date: Tue, 28 Feb 2023 18:53:44 +0000 (+0100) Subject: fritz-tools: fix segfault in caldata-extract X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=766270061305eb0ad18f241f907b321744b692bc;p=openwrt%2Fstaging%2Fblocktrron.git fritz-tools: fix segfault in caldata-extract * Fix incorrect error message in case input file opening fails * Don't close files in case the pointers are invalid Signed-off-by: David Bauer --- diff --git a/package/utils/fritz-tools/Makefile b/package/utils/fritz-tools/Makefile index a4d69bdf71..6e20b56ff8 100644 --- a/package/utils/fritz-tools/Makefile +++ b/package/utils/fritz-tools/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fritz-tools -PKG_RELEASE:=1 +PKG_RELEASE:=2 CMAKE_INSTALL:=1 include $(INCLUDE_DIR)/package.mk diff --git a/package/utils/fritz-tools/src/fritz_cal_extract.c b/package/utils/fritz-tools/src/fritz_cal_extract.c index 8156dfd1a7..2978d86e0c 100644 --- a/package/utils/fritz-tools/src/fritz_cal_extract.c +++ b/package/utils/fritz-tools/src/fritz_cal_extract.c @@ -210,7 +210,7 @@ int main(int argc, char **argv) if (argc > 1 && optind <= argc) { in = fopen(argv[optind], "r"); if (!in) { - perror("Failed to create output file"); + perror("Failed to open input file"); goto out_bad; } } @@ -253,7 +253,9 @@ out_bad: ret = EXIT_FAILURE; out: - fclose(in); - fclose(out); + if (in) + fclose(in); + if (out) + fclose(out); return ret; }