ソースを参照

libdpkg: Do not match partial field names in control files

There is currently no instance of any misspelled field names known to
dpkg in Debian. Only known field names are possibly affected.

Regression introduced in commit 864e230e90de1cef94c81f10582e6d99717d593b.

Closes: #769119
Guillem Jover 11 年 前
コミット
611305ef0e
共有2 個のファイルを変更した6 個の追加2 個の削除を含む
  1. 2 0
      debian/changelog
  2. 4 2
      lib/dpkg/parse.c

+ 2 - 0
debian/changelog

@@ -15,6 +15,8 @@ dpkg (1.17.22) UNRELEASED; urgency=low
     and they come from the package fields, which are under user control.
     and they come from the package fields, which are under user control.
     Regression introduced in dpkg 1.16.0. Fixes CVE-2014-8625. Closes: #768485
     Regression introduced in dpkg 1.16.0. Fixes CVE-2014-8625. Closes: #768485
     Reported by Joshua Rogers <megamansec@gmail.com>.
     Reported by Joshua Rogers <megamansec@gmail.com>.
+  * Do not match partial field names in control files. Closes: #769119
+    Regression introduced in dpkg 1.10.
 
 
   [ Updated programs translations ]
   [ Updated programs translations ]
   * German (Sven Joachim).
   * German (Sven Joachim).

+ 4 - 2
lib/dpkg/parse.c

@@ -131,7 +131,8 @@ pkg_parse_field(struct parsedb_state *ps, struct field_state *fs,
   }
   }
 
 
   for (fip = fieldinfos, ip = fs->fieldencountered; fip->name; fip++, ip++)
   for (fip = fieldinfos, ip = fs->fieldencountered; fip->name; fip++, ip++)
-    if (strncasecmp(fip->name, fs->fieldstart, fs->fieldlen) == 0)
+    if (strncasecmp(fip->name, fs->fieldstart, fs->fieldlen) == 0 &&
+        fip->name[fs->fieldlen] == '\0')
       break;
       break;
   if (fip->name) {
   if (fip->name) {
     if ((*ip)++)
     if ((*ip)++)
@@ -152,7 +153,8 @@ pkg_parse_field(struct parsedb_state *ps, struct field_state *fs,
                   fs->fieldlen, fs->fieldstart);
                   fs->fieldlen, fs->fieldstart);
     larpp = &pkg_obj->pkgbin->arbs;
     larpp = &pkg_obj->pkgbin->arbs;
     while ((arp = *larpp) != NULL) {
     while ((arp = *larpp) != NULL) {
-      if (strncasecmp(arp->name, fs->fieldstart, fs->fieldlen) == 0)
+      if (strncasecmp(arp->name, fs->fieldstart, fs->fieldlen) == 0 &&
+          arp->name[fs->fieldlen] == '\0')
         parse_error(ps,
         parse_error(ps,
                    _("duplicate value for user-defined field `%.*s'"),
                    _("duplicate value for user-defined field `%.*s'"),
                    fs->fieldlen, fs->fieldstart);
                    fs->fieldlen, fs->fieldstart);