소스 검색

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 <saurik@saurik.com>
Stable-Candidate: 1.17.x
Guillem Jover 9 년 전
부모
커밋
eeeae2acc8
3개의 변경된 파일16개의 추가작업 그리고 5개의 파일을 삭제
  1. 5 0
      debian/changelog
  2. 3 1
      lib/dpkg/dpkg-db.h
  3. 8 4
      lib/dpkg/parse.c

+ 5 - 0
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 <saurik@saurik.com>.
+
   [ Updated programs translations ]
   * Turkish (Mert Dirik). Closes: #853202
 

+ 3 - 1
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. */

+ 8 - 4
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))