abrt/0002-hooklib-Proper-freeing-of-backtrace.patch
2020-10-13 11:11:22 +02:00

41 lines
1.4 KiB
Diff

From 5fa7b1f84fb02ca5dcf50d27f4bc14563c1918f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mat=C4=9Bj=20Grabovsk=C3=BD?= <mgrabovs@redhat.com>
Date: Mon, 12 Oct 2020 19:14:03 +0200
Subject: [PATCH] hooklib: Proper freeing of backtrace
Improper bracing caused the bt variable to be freed every time in every
iteration no matter what. This would then lead to an invalid (freed)
pointer being returned by the function.
The mistake was made in 1f2963b0 and reported by Jeff Law.
---
src/lib/hooklib.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/lib/hooklib.c b/src/lib/hooklib.c
index 56b77bc3..fc2a6a00 100644
--- a/src/lib/hooklib.c
+++ b/src/lib/hooklib.c
@@ -361,13 +361,17 @@ char *abrt_get_backtrace(struct dump_dir *dd, unsigned timeout_sec, const char *
bt_depth /= 2;
if (bt)
+ {
log_warning("Backtrace is too big (%u bytes), reducing depth to %u",
(unsigned)strlen(bt), bt_depth);
+ }
else
+ {
/* (NB: in fact, current impl. of exec_vp() never returns NULL) */
log_warning("Failed to generate backtrace, reducing depth to %u",
bt_depth);
- free(bt);
+ g_clear_pointer(&bt, free);
+ }
/* Replace -ex disassemble (which disasms entire function $pc points to)
* to a version which analyzes limited, small patch of code around $pc.
--
2.26.2