There do appear to be potentially 2 problems here:
1) the issue whereby /var/lib/dpkg/status is somehow truncated
"dpkg-query -l" indeed expects to find the following fields for a package as a minimum:
name, description, maintainer, version, status (required to actually get any output from "dpkg -l")
2) "dpkg-query -l" is segfaulting when given the invalid "status" file
The code detects the problem but rather than issuing an error message, it gets a SIGSEGV. What we expect to see from "dpkg -l" under the conditions in (1) is:
warning, in file '/var/lib/dpkg/status' near line 3 package 'dpkg':
missing description
warning, in file '/var/lib/dpkg/status' near line 3 package 'dpkg':
missing maintainer
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=============================-=============================-==========================================================================
ii dpkg 1.15.8.5ubuntu1
______
I've looked at (2) first: the problem is observed when va_end() is called in lib/dpkg/parsehelp.c:parse_warn(). Call hierarchy is:
modstatdb_init() -> parsedb() -> parse_ensure_have_field() -> parse_warn(). Once the function returns (just after calling va_end()), the stack has been trashed. valgrind is alas no help here as it fails on armel ("valgrind: the 'impossible' happened" [bug to be raised]).
There do appear to be potentially 2 problems here:
1) the issue whereby /var/lib/ dpkg/status is somehow truncated
"dpkg-query -l" indeed expects to find the following fields for a package as a minimum:
name, description, maintainer, version, status (required to actually get any output from "dpkg -l")
2) "dpkg-query -l" is segfaulting when given the invalid "status" file
The code detects the problem but rather than issuing an error message, it gets a SIGSEGV. What we expect to see from "dpkg -l" under the conditions in (1) is:
warning, in file '/var/lib/ dpkg/status' near line 3 package 'dpkg': dpkg/status' near line 3 package 'dpkg': Unknown/ Install/ Remove/ Purge/Hold Not/Inst/ Conf-files/ Unpacked/ halF-conf/ Half-inst/ trig-aWait/ Trig-pend /Reinst- required (Status,Err: uppercase=bad) ======= ======= ======= =====-= ======= ======= ======= ======= -====== ======= ======= ======= ======= ======= ======= ======= ======= ======= =====
missing description
warning, in file '/var/lib/
missing maintainer
Desired=
| Status=
|/ Err?=(none)
||/ Name Version Description
+++-===
ii dpkg 1.15.8.5ubuntu1
______
I've looked at (2) first: the problem is observed when va_end() is called in lib/dpkg/ parsehelp. c:parse_ warn(). Call hierarchy is: have_field( ) -> parse_warn(). Once the function returns (just after calling va_end()), the stack has been trashed. valgrind is alas no help here as it fails on armel ("valgrind: the 'impossible' happened" [bug to be raised]).
modstatdb_init() -> parsedb() -> parse_ensure_