From e350b23a63577ca10a517ece13f8ab177034e594 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 13 Feb 2007 00:56:14 +0000 Subject: [PATCH] Exit with an error instead of an assert if the number of conflictors is exceeded. Remove bogus comments. Closes: #377855 --- ChangeLog | 8 ++++++++ debian/changelog | 2 ++ src/archives.c | 13 +++++++------ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c613ddc2..80333a84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-02-13 Guillem Jover + + * 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 * dpkg-deb/build.c (getfi): Exit with an error instead of an assert. diff --git a/debian/changelog b/debian/changelog index 37f784d7..db08eb01 100644 --- a/debian/changelog +++ b/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). diff --git a/src/archives.c b/src/archives.c index a0a5c35b..0ba14d55 100644 --- a/src/archives.c +++ b/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 %.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); -- 2.39.5