[openwrt/openwrt] fritz-tools: fix segfault in caldata-extract

LEDE Commits lede-commits at lists.infradead.org
Thu Mar 2 08:04:35 PST 2023


blocktrron pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/766270061305eb0ad18f241f907b321744b692bc

commit 766270061305eb0ad18f241f907b321744b692bc
Author: David Bauer <mail at david-bauer.net>
AuthorDate: Tue Feb 28 19:53:44 2023 +0100

    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 <mail at david-bauer.net>
---
 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;
 }




More information about the lede-commits mailing list