Explorar o código

libdpkg: Properly increment seen fields in a stanza

The current code was not incrementing the contents of the pointed area,
but the pointer itself, which was making the check for already seen
(duplicate) fields a no-op, and thus non-fatal, contrary to what was
intended originally.

This should not be a problem in general as the tools in charge of
generating binary packages error out in case of duplicate fields, so
there should not be many broken packages on the wild.

This was spotted by a run with the clang static analyzer.
Guillem Jover %!s(int64=16) %!d(string=hai) anos
pai
achega
683d18a891
Modificáronse 2 ficheiros con 5 adicións e 1 borrados
  1. 4 0
      debian/changelog
  2. 1 1
      lib/dpkg/parse.c

+ 4 - 0
debian/changelog

@@ -29,6 +29,10 @@ dpkg (1.15.6) UNRELEASED; urgency=low
     Closes: #560010
   * Do not allow diverting a file to itself, which makes the file to get
     removed. Closes: #312206
+  * Make the check for duplicate fields in a stanza in libdpkg actually work,
+    which now makes it fatal, as was intended originally. This should not
+    cause problems for anything using dpkg-dev to build packages as those
+    are already fatal on that case.
 
   [ Updated man page translations ]
   * French (Christian Perrier): correcting inconsistencies for the translation

+ 1 - 1
lib/dpkg/parse.c

@@ -218,7 +218,7 @@ int parsedb(const char *filename, enum parsedbflags flags,
         value = m_realloc(value, valuelen + 1);
 	memcpy(value,valuestart,valuelen);
         *(value + valuelen) = '\0';
-        if (*ip++)
+        if ((*ip)++)
           parse_error(&ps, &newpig,
                       _("duplicate value for `%s' field"), fip->name);
         fip->rcall(&newpig, newpifp, &ps, value, fip);