From 766270061305eb0ad18f241f907b321744b692bc Mon Sep 17 00:00:00 2001 From: David Bauer Date: Tue, 28 Feb 2023 19:53:44 +0100 Subject: [PATCH] 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 --- package/utils/fritz-tools/Makefile | 2 +- package/utils/fritz-tools/src/fritz_cal_extract.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) 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; } -- 2.30.2