[PATCH] trace: fix potential use-after-free occurence

vincent at systemli.org vincent at systemli.org
Mon Aug 30 13:37:10 PDT 2021


From: Nick Hainke <vincent at systemli.org>

char* tmp is used in the fprintf function altough it is already freed.

Fixes: e5b38fd1 ("trace: free memory allocated by blobmsg_format_json_indent()")

Signed-off-by: Nick Hainke <vincent at systemli.org>
---
 trace/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/trace/trace.c b/trace/trace.c
index 87a98a6..40cf3df 100644
--- a/trace/trace.c
+++ b/trace/trace.c
@@ -166,8 +166,8 @@ static void print_syscalls(int policy, const char *json)
 			if (!tmp)
 				return;
 
-			free(tmp);
 			fprintf(fp, "%s\n", tmp);
+			free(tmp);
 			fclose(fp);
 			ULOG_INFO("saving syscall trace to %s\n", json);
 		} else {
-- 
2.33.0




More information about the openwrt-devel mailing list