Przeglądaj źródła

libdpkg: Allow again unknown Priority field values

The code was not properly advancing the end of the value string when
reaching the fallback case (on values not known for the Priority field),
and the validation for junk after the first word was failing on the
actual first word.

This change reverts to the previous behaviour of blindly accepting the
whole value string for a field, regardless of it being multiword, when
it's the fallback case.

Regression introduced in commit b3f669039f128d715ac7ac71abaeac86f0954112.

Analysis-by: Raphaël Hertzog <hertzog@debian.org>
Analysis-by: Guillem Jover <guillem@debian.org>
Guillem Jover 15 lat temu
rodzic
commit
d84b36a810
2 zmienionych plików z 16 dodań i 4 usunięć
  1. 7 0
      debian/changelog
  2. 9 4
      lib/dpkg/fields.c

+ 7 - 0
debian/changelog

@@ -1,3 +1,10 @@
+dpkg (1.16.0.3) UNRELEASED; urgency=low
+
+  * Allow again Priority field values not known to dpkg. Regression
+    introduced in 1.16.0.
+
+ -- Guillem Jover <guillem@debian.org>  Wed, 04 May 2011 09:39:09 +0200
+
 dpkg (1.16.0.2) unstable; urgency=high
 
   * Fix dpkg-split --auto to not fail when opening the new depot file.

+ 9 - 4
lib/dpkg/fields.c

@@ -48,9 +48,14 @@ parse_nv_next(struct parsedb_state *ps, const struct pkginfo *pigp,
   if (nv == NULL)
     parse_error(ps, pigp, _("'%.50s' is not allowed for %s"), str_start, what);
 
-  str_end = str_start + nv->length;
-  while (isspace(str_end[0]))
-    str_end++;
+  /* We got the fallback value, skip further string validation. */
+  if (nv->length == 0) {
+    str_end = NULL;
+  } else {
+    str_end = str_start + nv->length;
+    while (isspace(str_end[0]))
+      str_end++;
+  }
   *strp = str_end;
 
   return nv->value;
@@ -64,7 +69,7 @@ parse_nv_last(struct parsedb_state *ps, const struct pkginfo *pkg,
   int value;
 
   value = parse_nv_next(ps, pkg, what, nv_head, &str);
-  if (str[0] != '\0')
+  if (str != NULL && str[0] != '\0')
     parse_error(ps, pkg, _("junk after %s"), what);
 
   return value;