Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | rpm: opendb before rpmverifyscript to avoid null point input |
| 2 | |
| 3 | If the command is "rpm -V" and the return value of (headerIsEntry(h, RPMTAG_VERIFYSCRIPT) |
| 4 | || headerIsEntry(h, RPMTAG_SANITYCHECK)) located in /lib/verify.c is true, it will call |
| 5 | rpmpsmStage function(rpmVerifyScript->rpmpsmScriptStage->rpmpsmStage) and occur segment |
| 6 | fault because of null point(rpmtsGetRdb(ts) == NULL and rpmtsGetRdb(ts)->db_txn). |
| 7 | So we open rpmdb to avoid bad input when find headerIsEntry true. |
| 8 | |
| 9 | Upstream-Status: Pending |
| 10 | |
| 11 | Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com> |
| 12 | Index: rpm-5.4.14/lib/verify.c |
| 13 | =================================================================== |
| 14 | --- rpm-5.4.14.orig/lib/verify.c 2015-07-22 22:09:59.992895355 +0800 |
| 15 | +++ rpm-5.4.14/lib/verify.c 2015-08-13 10:20:33.752177906 +0800 |
| 16 | @@ -613,6 +613,8 @@ |
| 17 | { |
| 18 | FD_t fdo = fdDup(STDOUT_FILENO); |
| 19 | |
| 20 | + rpmtsOpenDB(ts, O_RDONLY); /*Open the DB to avoid null point input in function rpmpsmStage()*/ |
| 21 | + |
| 22 | rc = rpmfiSetHeader(fi, h); |
| 23 | if ((rc = rpmVerifyScript(qva, ts, fi, fdo)) != 0) |
| 24 | ec += rc; |