From eeeae2acc87ab380b732491d22af7ec3f4b6b772 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 30 Jan 2017 01:04:31 +0100 Subject: libdpkg: Turn status file parser errors on field blank lines into warnings Regression introduced in commit e4cb12a710457b103a7544c4de5e9fc1b2bd24d8. This has caused issues at least on Cydia installations. And it should have been introduced as a lax parsing error, only failing for new packages, and warn on already installed ones. Otherwise one cannot easily recover after upgrading to a new dpkg on an affected system. Reported-by: Jay Freeman Stable-Candidate: 1.17.x --- debian/changelog | 5 +++++ lib/dpkg/dpkg-db.h | 4 +++- lib/dpkg/parse.c | 12 ++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3237c46b6..8b6e1661c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,10 @@ dpkg (1.18.22) UNRELEASED; urgency=medium + [ Guillem Jover ] + * Turn status file parser errors on bogus field blank lines into warnings, + otherwise the system cannot be easily recovered from. Regression + introduced in dpkg 1.16.1. Reported by Jay Freeman . + [ Updated programs translations ] * Turkish (Mert Dirik). Closes: #853202 diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h index 0e678c5a6..bffd317ab 100644 --- a/lib/dpkg/dpkg-db.h +++ b/lib/dpkg/dpkg-db.h @@ -310,8 +310,10 @@ enum parsedbflags { pdb_ignoreolder = DPKG_BIT(5), /** Perform laxer version parsing. */ pdb_lax_version_parser = DPKG_BIT(6), + /** Perform laxer control stanza parsing. */ + pdb_lax_stanza_parser = DPKG_BIT(9), /** Perform laxer parsing, used to transition to stricter parsing. */ - pdb_lax_parser = pdb_lax_version_parser, + pdb_lax_parser = pdb_lax_stanza_parser | pdb_lax_version_parser, /** Close file descriptor on context destruction. */ pdb_close_fd = DPKG_BIT(7), /** Interpret filename ‘-’ as stdin. */ diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c index 2d7f0a35b..1b3bf13d8 100644 --- a/lib/dpkg/parse.c +++ b/lib/dpkg/parse.c @@ -673,10 +673,14 @@ parse_stanza(struct parsedb_state *ps, struct field_state *fs, fs->valuestart = ps->dataptr - 1; for (;;) { if (c == '\n' || c == MSDOS_EOF_CHAR) { - if (blank_line) - parse_error(ps, - _("blank line in value of field '%.*s'"), - fs->fieldlen, fs->fieldstart); + if (blank_line) { + if (ps->flags & pdb_lax_stanza_parser) + parse_warn(ps, _("blank line in value of field '%.*s'"), + fs->fieldlen, fs->fieldstart); + else + parse_error(ps, _("blank line in value of field '%.*s'"), + fs->fieldlen, fs->fieldstart); + } ps->lno++; if (parse_at_eof(ps)) -- cgit v1.2.3