Discussion:
[software/rpm/perl-URPM] 01/02: fix crashing in ptread when using log callback with rpm-4.12
root-odJJhXpcy38dnm+
2014-10-22 22:41:28 UTC
Permalink
This is an automated email from the git hooks/post-receive script.

tv pushed a commit to branch master
in repository software/rpm/perl-URPM.

commit 9da52289488329a59123d27dfc90f7b03801e89f
Author: Thierry Vignaud <thierry.vignaud-***@public.gmane.org>
Date: Thu Oct 23 00:23:12 2014 +0200

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.
---
Commit Link:
http://gitweb.mageia.org/software/rpm/perl-URPM/commit/?id=9da52289488329a59123d27dfc90f7b03801e89f

NEWS | 2 ++
URPM.xs | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)

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
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;
}
--
Mageia Git Monkeys.
root-odJJhXpcy38dnm+
2014-10-22 22:41:29 UTC
Permalink
This is an automated email from the git hooks/post-receive script.

tv pushed a commit to branch master
in repository software/rpm/perl-URPM.

commit ee9e2943da7afda9f2ac99348450431ba9ca20a1
Author: Thierry Vignaud <thierry.vignaud-***@public.gmane.org>
Date: Thu Oct 23 00:37:00 2014 +0200

5.01
---
Commit Link:
http://gitweb.mageia.org/software/rpm/perl-URPM/commit/?id=ee9e2943da7afda9f2ac99348450431ba9ca20a1

NEWS | 2 ++
URPM.pm | 2 +-
2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 9b687d1..ffb31ea 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+Version 5.01 - 23 October 2014
+
- fix crashing in ptread when using log callback with rpm-4.12

Version 5.00 - 12 September 2014
diff --git a/URPM.pm b/URPM.pm
index a386e81..d7a12f6 100644
--- a/URPM.pm
+++ b/URPM.pm
@@ -11,7 +11,7 @@ use URPM::Resolve;
use URPM::Signature;

our @ISA = qw(DynaLoader);
-our $VERSION = '5.00';
+our $VERSION = '5.01';

URPM->bootstrap($VERSION);
--
Mageia Git Monkeys.
root-odJJhXpcy38dnm+
2014-10-22 22:41:30 UTC
Permalink
This is an automated email from the git hooks/post-receive script.

tv pushed a commit to tag 5.01
in repository software/rpm/perl-URPM.

commit 6891e3b23fe22056a6b7a54b4cef2601651b93dc
Author: Thierry Vignaud <thierry.vignaud-***@public.gmane.org>
Date: Thu Oct 23 00:37:00 2014 +0200

5.01
---
Commit Link:
http://gitweb.mageia.org/software/rpm/perl-URPM/commit/?id=6891e3b23fe22056a6b7a54b4cef2601651b93dc

NEWS | 2 ++
URPM.pm | 2 +-
2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 9b687d1..ffb31ea 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+Version 5.01 - 23 October 2014
+
- fix crashing in ptread when using log callback with rpm-4.12

Version 5.00 - 12 September 2014
diff --git a/URPM.pm b/URPM.pm
index a386e81..d7a12f6 100644
--- a/URPM.pm
+++ b/URPM.pm
@@ -11,7 +11,7 @@ use URPM::Resolve;
use URPM::Signature;

our @ISA = qw(DynaLoader);
-our $VERSION = '5.00';
+our $VERSION = '5.01';

URPM->bootstrap($VERSION);
--
Mageia Git Monkeys.
root-odJJhXpcy38dnm+
2014-10-22 22:41:29 UTC
Permalink
This is an automated email from the git hooks/post-receive script.

tv pushed a commit to tag 5.01
in repository software/rpm/perl-URPM.

commit 13f4133e711f4e2642946582aea44e779d037c71
Author: Thierry Vignaud <thierry.vignaud-***@public.gmane.org>
Date: Thu Oct 23 00:23:12 2014 +0200

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 you 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.
---
Commit Link:
http://gitweb.mageia.org/software/rpm/perl-URPM/commit/?id=13f4133e711f4e2642946582aea44e779d037c71

NEWS | 2 ++
URPM.xs | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)

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
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;
}
--
Mageia Git Monkeys.
Loading...