aboutsummaryrefslogtreecommitdiffstats
path: root/URPM.xs
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2014-10-23 00:23:12 +0200
committerThierry Vignaud <thierry.vignaud@gmail.com>2014-10-23 00:37:22 +0200
commit9da52289488329a59123d27dfc90f7b03801e89f (patch)
tree72f5c5e83c916eb992d1d4ac095232f6ba321526 /URPM.xs
parent0f122c39101955dc584fe8e0dacfed17dfc7c831 (diff)
downloadperl-URPM-9da52289488329a59123d27dfc90f7b03801e89f.tar
perl-URPM-9da52289488329a59123d27dfc90f7b03801e89f.tar.gz
perl-URPM-9da52289488329a59123d27dfc90f7b03801e89f.tar.bz2
perl-URPM-9da52289488329a59123d27dfc90f7b03801e89f.tar.xz
perl-URPM-9da52289488329a59123d27dfc90f7b03801e89f.zip
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.
Diffstat (limited to 'URPM.xs')
-rw-r--r--URPM.xs4
1 files changed, 2 insertions, 2 deletions
diff --git a/URPM.xs b/URPM.xs
index 4a01edf..49e4124 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -121,8 +121,8 @@ static ssize_t write_nocheck(int fd, const void *buf, size_t count) {
}
static int rpmError_callback_data;
-static int rpmError_callback() {
- write_nocheck(rpmError_callback_data, rpmlogMessage(), strlen(rpmlogMessage()));
+static int rpmError_callback(rpmlogRec rec, rpmlogCallbackData data) {
+ write_nocheck(rpmError_callback_data, rpmlogRecMessage(rec), strlen(rpmlogRecMessage(rec)));
return RPMLOG_DEFAULT;
}