Blame SOURCES/0002-testcase_read-error-out-if-repos-are-added-or-the-system-is-changed-too-late.patch

3a0595
From 0956e7d1b1354860ab0bf7105c4477cb2c61539a Mon Sep 17 00:00:00 2001
3a0595
From: Michael Schroeder <mls@suse.de>
3a0595
Date: Mon, 14 Dec 2020 11:12:00 +0100
3a0595
Subject: [PATCH] testcase_read: error out if repos are added or the system is
3a0595
 changed too late
3a0595
3a0595
We must not add new solvables after the considered map was created, the solver
3a0595
was created, or jobs were added. We may not changed the system after jobs have
3a0595
been added.
3a0595
3a0595
(Jobs may point inside the whatproviedes array, so we must not invalidate this
3a0595
area.)
3a0595
---
3a0595
 ext/testcase.c | 21 +++++++++++++++++++++
3a0595
 1 file changed, 21 insertions(+)
3a0595
3a0595
diff --git a/ext/testcase.c b/ext/testcase.c
3a0595
index bd0643a8a..b81834faa 100644
3a0595
--- a/ext/testcase.c
3a0595
+++ b/ext/testcase.c
3a0595
@@ -1975,6 +1975,7 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
3a0595
   Id *genid = 0;
3a0595
   int ngenid = 0;
3a0595
   Queue autoinstq;
3a0595
+  int oldjobsize = job ? job->count : 0;
3a0595
 
3a0595
   if (resultp)
3a0595
     *resultp = 0;
3a0595
@@ -2049,6 +2050,21 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
3a0595
 	  int prio, subprio;
3a0595
 	  const char *rdata;
3a0595
 
3a0595
+	  if (pool->considered)
3a0595
+	    {
3a0595
+	      pool_error(pool, 0, "testcase_read: cannot add repos after packages were disabled");
3a0595
+	      continue;
3a0595
+	    }
3a0595
+	  if (solv)
3a0595
+	    {
3a0595
+	      pool_error(pool, 0, "testcase_read: cannot add repos after the solver was created");
3a0595
+	      continue;
3a0595
+	    }
3a0595
+	  if (job && job->count != oldjobsize)
3a0595
+	    {
3a0595
+	      pool_error(pool, 0, "testcase_read: cannot add repos after jobs have been created");
3a0595
+	      continue;
3a0595
+	    }
3a0595
 	  prepared = 0;
3a0595
           if (!poolflagsreset)
3a0595
 	    {
3a0595
@@ -2109,6 +2125,11 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
3a0595
 	  int i;
3a0595
 
3a0595
 	  /* must set the disttype before the arch */
3a0595
+	  if (job && job->count != oldjobsize)
3a0595
+	    {
3a0595
+	      pool_error(pool, 0, "testcase_read: cannot change the system after jobs have been created");
3a0595
+	      continue;
3a0595
+	    }
3a0595
 	  prepared = 0;
3a0595
 	  if (strcmp(pieces[2], "*") != 0)
3a0595
 	    {