Quellcode durchsuchen

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 vor 11 Jahren
Ursprung
Commit
611305ef0e
2 geänderte Dateien mit 6 neuen und 2 gelöschten Zeilen
  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.
     Regression introduced in dpkg 1.16.0. Fixes CVE-2014-8625. Closes: #768485
     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 ]
   * 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++)
-    if (strncasecmp(fip->name, fs->fieldstart, fs->fieldlen) == 0)
+    if (strncasecmp(fip->name, fs->fieldstart, fs->fieldlen) == 0 &&
+        fip->name[fs->fieldlen] == '\0')
       break;
   if (fip->name) {
     if ((*ip)++)
@@ -152,7 +153,8 @@ pkg_parse_field(struct parsedb_state *ps, struct field_state *fs,
                   fs->fieldlen, fs->fieldstart);
     larpp = &pkg_obj->pkgbin->arbs;
     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,
                    _("duplicate value for user-defined field `%.*s'"),
                    fs->fieldlen, fs->fieldstart);