From 9da52289488329a59123d27dfc90f7b03801e89f Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Thu, 23 Oct 2014 00:23:12 +0200 Subject: fix crashing in ptread when using log callback with rpm-4.12 fix by Panu Matilainen When rpmlog() occurs, it now grabs a read/write lock on the log context depending on whether it needs to save the log or not. The callback executes while the context lock is held, so when one call rpmlogMessage() or pretty much any rpmlog-related function from the callback, it'll try to lock the context again. Which is okay as long as rpmlog() only needed a read-lock on the context. However if it has a write-lock then attempting to grab a read-lock for rpmlogMessage() fails, but due to the largely missing error handling in rpmlog.c it falls through to crash and burn. The only reason we need to call rpmlogMessage() is that the callback does not match the callback function type in rpm >= 4.6: typedef int (*rpmlogCallback) (rpmlogRec rec, rpmlogCallbackData data); We shouldn't call that from log callback. We can avoid the issue by using rpmlogRecMessage() instead of rpmlogMessage() inside the callback. These are not the same, rpmlogRecMessage() returns the message of the *current* log event, whereas rpmlogMessage() returns the last *saved* log event. Which might not exist, might be from an earlier event or it might be the current event. ...and it'll not only work in all rpm >= 4.6 versions, but also give the actual log message at hand, instead of something that might have happened in the past. --- NEWS | 2 ++ 1 file changed, 2 insertions(+) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 9028bb4..9b687d1 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +- fix crashing in ptread when using log callback with rpm-4.12 + Version 5.00 - 12 September 2014 - make it compatible with rpm-4.12.0 -- cgit v1.2.1