Просмотр исходного кода

Exit with an error instead of an assert if the number of conflictors is
exceeded. Remove bogus comments. Closes: #377855

Guillem Jover лет назад: 19
Родитель
Сommit
e350b23a63
3 измененных файлов с 17 добавлено и 6 удалено
  1. 8 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 7 6
      src/archives.c

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2007-02-13  Guillem Jover  <guillem@debian.org>
+
+	* src/archives.c (MAXCONFLICTORS): New macro.
+	(conflictor): Use MAXCONFLICTORS instad of hardcoded value '20', and
+	remove non-matching comments.
+	(check_conflict): Exit with an error instead of an assert. Move part
+	of the comment to the error message, remove the rest as non-matching.
+
 2007-02-13  Guillem Jover  <guillem@debian.org>
 
 	* dpkg-deb/build.c (getfi): Exit with an error instead of an assert.

+ 2 - 0
debian/changelog

@@ -34,6 +34,8 @@ dpkg (1.14.0) UNRELEASED; urgency=low
   * Check proper error value returned by BZ2_bzerror. Closes: #410605
   * Exit with an error instead of an assert if a file name is too long when
     building a .deb package. Closes: #393069
+  * Exit with an error instead of an assert if the number of conflictors is
+    exceeded. Remove bogus comments. Closes: #377855
 
   [ Updated dpkg translations ]
   * Romanian (Eddy Petrișor).

+ 7 - 6
src/archives.c

@@ -53,8 +53,9 @@ static security_context_t scontext    = NULL;
 #include "main.h"
 #include "archives.h"
 
-/* We shouldn't need anymore than 10 conflictors */
-struct pkginfo *conflictor[20];
+#define MAXCONFLICTORS 20
+
+struct pkginfo *conflictor[MAXCONFLICTORS];
 int cflict_index = 0;
 
 /* snprintf(3) doesn't work if format contains %.<nnn>s and an argument has
@@ -898,10 +899,10 @@ void check_conflict(struct dependency *dep, struct pkginfo *pkg,
         }
       }
       if (!pdep) {
-	/* if this gets triggered, it means a package has > 10 conflicts/replaces
-	 * pairs, which is the package's fault
-	 */
-	assert(cflict_index < (int)sizeof(conflictor));
+	if (cflict_index >= MAXCONFLICTORS)
+	  ohshit(_("package %s has too many Conflicts/Replaces pairs"),
+		 pkg->name);
+
         /* This conflict is OK - we'll remove the conflictor. */
 	conflictor[cflict_index++]= fixbyrm;
         varbuffree(&conflictwhy); varbuffree(&removalwhy);