]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
testcase_read: error out if repos are added or the system is changed too late
authorMichael Schroeder <mls@suse.de>
Mon, 14 Dec 2020 10:12:00 +0000 (11:12 +0100)
committerMichael Schroeder <mls@suse.de>
Thu, 20 May 2021 10:00:25 +0000 (12:00 +0200)
We must not add new solvables after the considered map was created, the solver
was created, or jobs were added. We may not changed the system after jobs have
been added.

(Jobs may point inside the whatproviedes array, so we must not invalidate this
area.)

ext/testcase.c

index 72743504a3c03c0fec2a47b697f39e6e47eabfe1..458d19b710d34552bae9e16d88c403c6226ad061 100644 (file)
@@ -2559,6 +2559,7 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
   Id *genid = 0;
   int ngenid = 0;
   Queue autoinstq;
+  int oldjobsize = job ? job->count : 0;
 
   if (resultp)
     *resultp = 0;
@@ -2627,6 +2628,21 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
          int prio, subprio;
          const char *rdata;
 
+         if (pool->considered)
+           {
+             pool_error(pool, 0, "testcase_read: cannot add repos after packages were disabled");
+             continue;
+           }
+         if (solv)
+           {
+             pool_error(pool, 0, "testcase_read: cannot add repos after the solver was created");
+             continue;
+           }
+         if (job && job->count != oldjobsize)
+           {
+             pool_error(pool, 0, "testcase_read: cannot add repos after jobs have been created");
+             continue;
+           }
          prepared = 0;
           if (!poolflagsreset)
            {
@@ -2687,6 +2703,11 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
          int i;
 
          /* must set the disttype before the arch */
+         if (job && job->count != oldjobsize)
+           {
+             pool_error(pool, 0, "testcase_read: cannot change the system after jobs have been created");
+             continue;
+           }
          prepared = 0;
          if (strcmp(pieces[2], "*") != 0)
            {