From: Michael Schroeder Date: Wed, 23 Feb 2011 18:09:03 +0000 (+0100) Subject: - repo_solv: add some type/storage checks X-Git-Tag: BASE-SuSE-Code-12_1-Branch~135 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ace3c2ac74401e1b72fb06e562a9017412f5863b;p=thirdparty%2Flibsolv.git - repo_solv: add some type/storage checks --- diff --git a/src/repo_solv.c b/src/repo_solv.c index c3f07928..bfe22db8 100644 --- a/src/repo_solv.c +++ b/src/repo_solv.c @@ -843,10 +843,29 @@ repo_add_solv_flags(Repo *repo, FILE *fp, int flags) keys[i].type = type; keys[i].size = read_id(&data, keys[i].type == REPOKEY_TYPE_CONSTANTID ? numid + numrel : 0); keys[i].storage = read_id(&data, 0); - if (id >= SOLVABLE_NAME && id <= RPM_RPMDBID) - keys[i].storage = KEY_STORAGE_SOLVABLE; - else if (keys[i].storage == KEY_STORAGE_SOLVABLE) + /* old versions used SOLVABLE for main solvable data */ + if (keys[i].storage == KEY_STORAGE_SOLVABLE) keys[i].storage = KEY_STORAGE_INCORE; + if (keys[i].storage != KEY_STORAGE_INCORE && keys[i].storage != KEY_STORAGE_VERTICAL_OFFSET) + { + pool_debug(pool, SAT_ERROR, "unsupported storage type %d\n", keys[i].storage); + data.error = SOLV_ERROR_UNSUPPORTED; + } + if (id >= SOLVABLE_NAME && id <= RPM_RPMDBID) + { + if (keys[i].storage != KEY_STORAGE_INCORE) + { + pool_debug(pool, SAT_ERROR, "main solvable data must use incore storage%d\n", keys[i].storage); + data.error = SOLV_ERROR_UNSUPPORTED; + } + keys[i].storage = KEY_STORAGE_SOLVABLE; + } + /* cannot handle rel idarrays in incore/vertical */ + if (type == REPOKEY_TYPE_REL_IDARRAY && keys[i].storage != KEY_STORAGE_SOLVABLE) + { + pool_debug(pool, SAT_ERROR, "type REL_IDARRAY only supported for STORAGE_SOLVABLE\n"); + data.error = SOLV_ERROR_UNSUPPORTED; + } if (keys[i].type == REPOKEY_TYPE_CONSTANTID) { if (idmap) @@ -1034,7 +1053,7 @@ printf("=> %s %s %p\n", id2str(pool, keys[key].name), id2str(pool, keys[key].typ dps = dp; dp = data_skip(dp, REPOKEY_TYPE_ID); dp = data_skip(dp, REPOKEY_TYPE_ID); - incore_add_blob(&data, dps, dp - dps); + incore_add_blob(&data, dps, dp - dps); /* just record offset/size */ continue; } switch (keys[key].type)