Fix rpm2cpio segment fault
cover Fix rpm2cpio segment fault
The following changes since commit d7b248e715d99766bf8602ff9f038f8b0afa5e78:
augeas: change SRC_URI (2013-02-26 08:02:29 -0800)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib kangkai/fix-rpm2cpio
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/fix-rpm2cpio
Kang Kai (1):
rpm: fix rpm2cpio segmentation fault
.../rpm/rpm/rpm2cpio-fix-segmentation-fault.patch | 24 ++++++++++++++++++++ meta/recipes-devtools/rpm/rpm_5.4.9.bb | 3 +- 2 files changed, 26 insertions(+), 1 deletions(-) create mode 100644 meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch
Signature · 1 line
1.7.5.4
PATCH 1/1 rpm: fix rpm2cpio segmentation fault
When run rpm2cpio, it fails with segmentation fault. The root cause is no macro "_db_path" defined, when query its value get nothing then cause segment fault.
Add patch to parse macro files first to fix this problem.
[YOCTO #3656]
--- .../rpm/rpm/rpm2cpio-fix-segmentation-fault.patch | 24 ++++++++++++++++++++ meta/recipes-devtools/rpm/rpm_5.4.9.bb | 3 +- 2 files changed, 26 insertions(+), 1 deletions(-) create mode 100644 meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch
meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch new file +24 -0
@@ -0,0 +1,24 @@ +Upstream-Status: Pending + +rpm2cpio fails on target with "Segmentation fault". Because no "_dbpath" +defined, when query it will cause seg fault. +Parse macro files first to fix this bug. + +[YOCTO #3656] + +Signed-off-by: Kang Kai <[email protected]> + +--- rpm-5.4.9/tools/rpm2cpio.c.orig 2013-02-28 13:14:12.453540767 +0800 ++++ rpm-5.4.9/tools/rpm2cpio.c 2013-02-28 15:09:41.685785192 +0800 +@@ -88,6 +88,11 @@ int main(int argc, char **argv) + (void) rpmtsSetVSFlags(ts, vsflags); + + /*@-mustmod@*/ /* LCL: segfault */ ++ rc = rpmReadConfigFiles(NULL, NULL); ++ if (rc) { ++ fprintf(stderr, _("read RPM config files failed\n")); ++ exit(EXIT_FAILURE); ++ } + rc = rpmReadPackageFile(ts, fdi, "rpm2cpio", &h); + /*@=mustmod@*/ +
meta/recipes-devtools/rpm/rpm_5.4.9.bb +2 -1
@@ -43,7 +43,7 @@ LICENSE = "LGPLv2.1" LIC_FILES_CHKSUM = "file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1" DEPENDS = "libpcre attr acl popt ossp-uuid file bison-native" -PR = "r61" +PR = "r62" # rpm2cpio is a shell script, which is part of the rpm src.rpm. It is needed # in order to extract the distribution SRPM into a format we can extract...
@@ -85,6 +85,7 @@ SRC_URI = "http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.9-0.20120508.src.rpm;ex file://rpm-reloc-macros.patch \ file://rpm-platform2.patch \ file://rpm-remove-sykcparse-decl.patch \ + file://rpm2cpio-fix-segmentation-fault.patch \ " # Uncomment the following line to enable platform score debugging
Signature · 1 line
1.7.5.4
Re: [PATCH 1/1] rpm: fix rpm2cpio segmentation fault
Quoted 35 lines · Kang Kai
When run rpm2cpio, it fails with segmentation fault. The root cause is no macro "
_db_path" defined, when query its value get nothing then cause segment fault.Add patch to parse macro files first to fix this problem.
[YOCTO #3656]
Signed-off-by Kang Kai <[email protected]>--- .../rpm/rpm/rpm2cpio-fix-segmentation-fault.patch | 24 ++++++++++++++++++++ meta/recipes-devtools/rpm/rpm_5.4.9.bb | 3 +- 2 files changed, 26 insertions(+), 1 deletions(-)create mode 100644
meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patchmeta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch new file +14
-0@@ -0,0 +1,24 @@ +Upstream-Status: Pending + +rpm2cpio fails on target with "Segmentation fault". Because no "_dbpath" +defined, when query it will cause seg fault. +Parse macro files first to fix this bug. + +[YOCTO #3656] + +Signed-off-by: Kang Kai <[email protected]> + +--- rpm-5.4.9/tools/rpm2cpio.c.orig 2013-02-28 13:14:12.453540767 +0800 ++++ rpm-5.4.9/tools/rpm2cpio.c 2013-02-28 15:09:41.685785192 +0800 +@@ -88,6 +88,11 @@ int main(int argc, char **argv) + (void) rpmtsSetVSFlags(ts, vsflags);
meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch line 24
Quoted 10 lines
meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch new file +10
-0+ + /*@-mustmod@*/ /* LCL: segfault */ ++ rc = rpmReadConfigFiles(NULL, NULL); ++ if (rc) { ++ fprintf(stderr, _("read RPM config files failed\n")); ++ exit(EXIT_FAILURE); ++ } + rc = rpmReadPackageFile(ts, fdi, "rpm2cpio", &h); + /*@=mustmod@*/ +
In the RPM2CPIO case, I'm not sure that we want to exit here. It's certainly reasonable for the config files to be unavailable to us.
If the problem is that _dbpath is undefined (and it's needed for some reason), my suggestion is that "some value" be defined, even if it's to a non-existent location. It's be even better if we could simply avoid using the _dbpath at all in the rpm2cpio code.
(Note, to folks reading this. Normally in oe-core, if we use rpm2cpio, we're actually using a shell script version which does not have this problem. The rpm2cpio -binary- is used by people on the target or sometimes via the SDK to extract SRPM or RPM packages...)
Quoted 22 lines
meta/recipes-devtools/rpm/rpm_5.4.9.bb +2
-1@@ -43,7 +43,7 @@ LICENSE = "LGPLv2.1" LIC_FILES_CHKSUM = "file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1" DEPENDS = "libpcre attr acl popt ossp-uuid file bison-native" -PR = "r61" +PR = "r62" # rpm2cpio is a shell script, which is part of the rpm src.rpm. It is needed # in order to extract the distribution SRPM into a format we can extract...@@ -85,6 +85,7 @@ SRC_URI = "http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.9-0.20120508.src.rpm;ex file://rpm-reloc-macros.patch \ file://rpm-platform2.patch \ file://rpm-remove-sykcparse-decl.patch \ + file://rpm2cpio-fix-segmentation-fault.patch \ " # Uncomment the following line to enable platform score debugging
Re: [PATCH 1/1] rpm: fix rpm2cpio segmentation fault
Quoted 41 lines · Mark Hatle
Quoted 40 lines · Kang Kai
When run rpm2cpio, it fails with segmentation fault. The root cause is no macro "
_db_path" defined, when query its value get nothing then cause segment fault.Add patch to parse macro files first to fix this problem.
[YOCTO #3656]
Signed-off-by Kang Kai <[email protected]>---
.../rpm/rpm/rpm2cpio-fix-segmentation-fault.patch| 24
++++++++++++++++++++
meta/recipes-devtools/rpm/rpm_5.4.9.bb | 3 +-2 files changed, 26 insertions(+), 1 deletions(-)create mode 100644
meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch(quoted diff) +0
-0
b/meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patchmeta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch new file +3
-0@@ -0,0 +1,24 @@ +Upstream-Status: Pending + +rpm2cpio fails on target with "Segmentation fault". Because no"
_dbpath"meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch new file +13
-0+defined, when query it will cause seg fault. +Parse macro files first to fix this bug. + +[YOCTO #3656] + +Signed-off-by: Kang Kai <[email protected]> + +--- rpm-5.4.9/tools/rpm2cpio.c.orig 2013-02-28 13:14:12.453540767 +0800 ++++ rpm-5.4.9/tools/rpm2cpio.c 2013-02-28 15:09:41.685785192 +0800 +@@ -88,6 +88,11 @@ int main(int argc, char **argv) + (void) rpmtsSetVSFlags(ts, vsflags); + + /*@-mustmod@*/ /* LCL: segfault */
Quoted 9 lines
Quoted 8 lines
++ rc =
rpmReadConfigFiles(NULL, NULL);
++ if (rc) {
++fprintf(stderr, _("read RPM config files failed\n")); ++exit(EXIT_FAILURE);
++ }
+ rc =rpmReadPackageFile(ts, fdi, "rpm2cpio", &h);
+ /*@=mustmod@*/
+
Hi Mark,
Sorry for missed this mail.
Quoted 1 line
In the RPM2CPIO case, I'm not sure that we want to exit here. It's certainly reasonable for the config files to be unavailable to us.
How about just give warning without quit when read configure files fails?
Quoted 2 lines
If the problem is that
_dbpathis undefined (and it's needed for some reason), my suggestion is that "some value" be defined, even if it's to a non-existent location. It's be even better if we could simply avoid using the_dbpathat all in the rpm2cpio code.
The segment fault occurs on executing rpmReadPackageFile(). It is a library function in rpmdb/package.c. And it finally calls rpmdbNew(), and in rpmdbNew() it calls:
db->db_home = rpmdbURIPath( (home && *home ? home : _DB_HOME) );
home passed in is NULL, and _DB_HOME is defined by:
#define _DB_HOME "%{?_dbpath}"
Then segment fault occurs with xstrdup() because no value is definedfor _dbpath then it tries to xstrdup() a NULL value in rpmdbURIPath().
That is why I think parse configure files first in rpm2cpio is the way to fix the issue.
Regards,
Kai
Quoted 33 lines
(Note, to folks reading this. Normally in oe-core, if we use rpm2cpio, we're actually using a shell script version which does not have this problem. The rpm2cpio -binary- is used by people on the target or sometimes via the SDK to extract SRPM or RPM packages...)
Quoted 21 lines
meta/recipes-devtools/rpm/rpm_5.4.9.bb +0
-0@@ -43,7 +43,7 @@ LICENSE = "LGPLv2.1"
LIC_FILES_CHKSUM= "file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1"DEPENDS = "libpcre attr acl popt ossp-uuid file bison-native"
meta/recipes-devtools/rpm/rpm_5.4.9.bb +1
-1-PR = "r61" +PR = "r62"# rpm2cpio is a shell script, which is part of the rpm src.rpm. It is needed # in order to extract the distribution SRPM into a format we can extract...meta/recipes-devtools/rpm/rpm_5.4.9.bb +0
-0@@ -85,6 +85,7 @@ SRC_URI ="http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.9-0.20120508.src.rpm;ex file://rpm-reloc-macros.patch \
file://rpm-platform2.patch \
file://rpm-remove-sykcparse-decl.patch \
+ file://rpm2cpio-fix-segmentation-fault.patch \
"Quoted 2 lines
# Uncomment the following line to enable platform score debugging
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Re: [PATCH 1/1] rpm: fix rpm2cpio segmentation fault
Quoted 55 lines · Kang Kai
Quoted 44 lines · Mark Hatle
Quoted 43 lines · Kang Kai
When run rpm2cpio, it fails with segmentation fault. The root cause is no macro "
_db_path" defined, when query its value get nothing then cause segment fault.Add patch to parse macro files first to fix this problem.
[YOCTO #3656]
Signed-off-by Kang Kai <[email protected]>---
.../rpm/rpm/rpm2cpio-fix-segmentation-fault.patch| 24
++++++++++++++++++++
meta/recipes-devtools/rpm/rpm_5.4.9.bb | 3 +-2 files changed, 26 insertions(+), 1 deletions(-)create mode 100644
meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patchdiff --git
a/meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patchb/meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patchnew file mode 100644
index 0000000..b43a64e
---/dev/null
+++b/meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patchmeta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch new file +3
-0@@ -0,0 +1,24 @@ +Upstream-Status: Pending + +rpm2cpio fails on target with "Segmentation fault". Because no"
_dbpath"meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch new file +13
-0+defined, when query it will cause seg fault. +Parse macro files first to fix this bug. + +[YOCTO #3656] + +Signed-off-by: Kang Kai <[email protected]> + +--- rpm-5.4.9/tools/rpm2cpio.c.orig 2013-02-28 13:14:12.453540767 +0800 ++++ rpm-5.4.9/tools/rpm2cpio.c 2013-02-28 15:09:41.685785192 +0800 +@@ -88,6 +88,11 @@ int main(int argc, char **argv) + (void) rpmtsSetVSFlags(ts, vsflags); + + /*@-mustmod@*/ /* LCL: segfault */Quoted 9 lines
Quoted 8 lines
++ rc =
rpmReadConfigFiles(NULL, NULL);
++ if (rc) {
++fprintf(stderr, _("read RPM config files failed\n")); ++exit(EXIT_FAILURE);
++ }
+ rc =rpmReadPackageFile(ts, fdi, "rpm2cpio", &h);
+ /*@=mustmod@*/
+
Quoted 8 lines
Hi Mark,
Sorry for missed this mail.
Quoted 2 lines
In the RPM2CPIO case, I'm not sure that we want to exit here. It's certainly reasonable for the config files to be unavailable to us.
How about just give warning without quit when read configure files fails?
We shouldn't even need a warning. When rpm2cpio is used on a target, much of the time there is no associated RPM in use (or if it's available, there likely isn't a database/home configured.)
Quoted 10 lines
Quoted 5 lines
If the problem is that
_dbpathis undefined (and it's needed for some reason), my suggestion is that "some value" be defined, even if it's to a non-existent location. It's be even better if we could simply avoid using the_dbpathat all in the rpm2cpio code.The segment fault occurs on executing
rpmReadPackageFile(). It is a library function inrpmdb/package.c. And it finally callsrpmdbNew(), and inrpmdbNew()it calls:
Quoted 5 lines
db->db_home=rpmdbURIPath( (home && *home ? home : _DB_HOME) );home passed in is NULL, and
_DB_HOMEis defined by:#define
_DB_HOME"%{?_dbpath}"
Instead of a warning above, if we were unable to load the database configuration, can we just set the value of _dbpath to be "/tmp"? This should provide a valid 'home' path for any temp files, as well as avoid any load problems. If there is a configuration available, we can use it.
Quoted 50 lines
Then segment fault occurs with
xstrdup()because no value is definedfor_dbpaththen it tries toxstrdup()a NULL value inrpmdbURIPath().That is why I think parse configure files first in rpm2cpio is the way to fix the issue.
Regards,
KaiQuoted 40 lines
(Note, to folks reading this. Normally in oe-core, if we use rpm2cpio, we're actually using a shell script version which does not have this problem. The rpm2cpio -binary- is used by people on the target or sometimes via the SDK to extract SRPM or RPM packages...)
Quoted 25 lines
meta/recipes-devtools/rpm/rpm_5.4.9.bb +0
-0@@ -43,7 +43,7 @@ LICENSE = "LGPLv2.1"
LIC_FILES_CHKSUM= "file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1"DEPENDS = "libpcre attr acl popt ossp-uuid file bison-native"
meta/recipes-devtools/rpm/rpm_5.4.9.bb +1
-1-PR = "r61" +PR = "r62"# rpm2cpio is a shell script, which is part of the rpm src.rpm. It is needed # in order to extract the distribution SRPM into a format we can extract...meta/recipes-devtools/rpm/rpm_5.4.9.bb +0
-0@@ -85,6 +85,7 @@ SRC_URI ="http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.9-0.20120508.src.rpm;ex file://rpm-reloc-macros.patch \
file://rpm-platform2.patch \
file://rpm-remove-sykcparse-decl.patch \
+ file://rpm2cpio-fix-segmentation-fault.patch \
"Quoted 2 lines
# Uncomment the following line to enable platform score debugging
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Re: [PATCH 1/1] rpm: fix rpm2cpio segmentation fault
Quoted 59 lines · Mark Hatle
Quoted 58 lines · Kang Kai
Quoted 45 lines · Mark Hatle
Quoted 44 lines · Kang Kai
When run rpm2cpio, it fails with segmentation fault. The root cause is no macro "
_db_path" defined, when query its value get nothing then cause segment fault.Add patch to parse macro files first to fix this problem.
[YOCTO #3656]
Signed-off-by Kang Kai <[email protected]>---
.../rpm/rpm/rpm2cpio-fix-segmentation-fault.patch| 24
++++++++++++++++++++
meta/recipes-devtools/rpm/rpm_5.4.9.bb | 3 +-2 files changed, 26 insertions(+), 1 deletions(-)create mode 100644
meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patchdiff --git
a/meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patchb/meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patchnew file mode 100644
index 0000000..b43a64e
---/dev/null
+++b/meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patchmeta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch new file +3
-0@@ -0,0 +1,24 @@ +Upstream-Status: Pending + +rpm2cpio fails on target with "Segmentation fault". Because no"
_dbpath"meta/recipes-devtools/rpm/rpm/rpm2cpio-fix-segmentation-fault.patch new file +14
-0+defined, when query it will cause seg fault. +Parse macro files first to fix this bug. + +[YOCTO #3656] + +Signed-off-by: Kang Kai <[email protected]> + +--- rpm-5.4.9/tools/rpm2cpio.c.orig 2013-02-28 13:14:12.453540767 +0800 ++++ rpm-5.4.9/tools/rpm2cpio.c 2013-02-28 15:09:41.685785192 +0800 +@@ -88,6 +88,11 @@ int main(int argc, char **argv) + (void) rpmtsSetVSFlags(ts, vsflags); + + /*@-mustmod@*/ /* LCL: segfault */Quoted 9 lines
Quoted 8 lines
++ rc =
rpmReadConfigFiles(NULL, NULL);
++ if (rc) {
++fprintf(stderr, _("read RPM config files failed\n")); ++exit(EXIT_FAILURE);
++ }
+ rc =rpmReadPackageFile(ts, fdi, "rpm2cpio", &h);
+ /*@=mustmod@*/
+Hi Mark,
Quoted 25 lines
Quoted 6 lines
Sorry for missed this mail.
Quoted 2 lines
In the RPM2CPIO case, I'm not sure that we want to exit here. It's certainly reasonable for the config files to be unavailable to us.
How about just give warning without quit when read configure files fails?
We shouldn't even need a warning. When rpm2cpio is used on a target, much of the time there is no associated RPM in use (or if it's available, there likely isn't a database/home configured.)
Quoted 15 lines
Quoted 5 lines
If the problem is that
_dbpathis undefined (and it's needed for some reason), my suggestion is that "some value" be defined, even if it's to a non-existent location. It's be even better if we could simply avoid using the_dbpathat all in the rpm2cpio code.The segment fault occurs on executing
rpmReadPackageFile(). It is a library function inrpmdb/package.c. And it finally callsrpmdbNew(), and inrpmdbNew()it calls:
db->db_home=rpmdbURIPath( (home && *home ? home : _DB_HOME) );home passed in is NULL, and
_DB_HOMEis defined by:#define
_DB_HOME"%{?_dbpath}"
Hi Mark,
Quoted 1 line
Instead of a warning above, if we were unable to load the database configuration, can we just set the value of
_dbpathto be "/tmp"? This should provide a valid 'home' path for any temp files, as well as avoid any load problems. If there is a configuration available, we can use it.
More vars found need to be set with a value. When run rpm2cpio, it calls rpmReadPackageFile() to open the rpm file, and then do some read and test work. When call rpmVerifySignature() it calls rpmdbOpen() and finally calls db3new(). In function db3new() in rpmdb/dbconfig.c around line 485, vars "_dbi_config_*" are expanded and var "_dbi_config" is asserted not to be NULL. But without parsing the macros file, assertion fails. "_dbi_config" is a complicated var and seems can not be set directly.
Would you like to give more help?
Thanks,
Kai
Quoted 53 lines
Quoted 51 lines
Then segment fault occurs with
xstrdup()because no value is definedfor_dbpaththen it tries toxstrdup()a NULL value inrpmdbURIPath().That is why I think parse configure files first in rpm2cpio is the way to fix the issue.
Regards,
KaiQuoted 40 lines
(Note, to folks reading this. Normally in oe-core, if we use rpm2cpio, we're actually using a shell script version which does not have this problem. The rpm2cpio -binary- is used by people on the target or sometimes via the SDK to extract SRPM or RPM packages...)
Quoted 25 lines
meta/recipes-devtools/rpm/rpm_5.4.9.bb +0
-0@@ -43,7 +43,7 @@ LICENSE = "LGPLv2.1"
LIC_FILES_CHKSUM= "file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1"DEPENDS = "libpcre attr acl popt ossp-uuid file bison-native"
meta/recipes-devtools/rpm/rpm_5.4.9.bb +1
-1-PR = "r61" +PR = "r62"# rpm2cpio is a shell script, which is part of the rpm src.rpm. It is needed # in order to extract the distribution SRPM into a format we can extract...meta/recipes-devtools/rpm/rpm_5.4.9.bb +0
-0@@ -85,6 +85,7 @@ SRC_URI ="http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.9-0.20120508.src.rpm;ex file://rpm-reloc-macros.patch \
file://rpm-platform2.patch \
file://rpm-remove-sykcparse-decl.patch \
+ file://rpm2cpio-fix-segmentation-fault.patch \
"Quoted 2 lines
# Uncomment the following line to enable platform score debugging
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Signature · 2 lines
Regards, Neil | Kai Kang