Make sure that downloaded pkg-index.plist is really a plist file.

This commit is contained in:
Juan RP 2011-10-28 09:29:37 +02:00
parent 8bc705ea63
commit dbd5e05280
2 changed files with 19 additions and 0 deletions

4
NEWS
View File

@ -1,5 +1,9 @@
xbps-0.10.2 (???): xbps-0.10.2 (???):
* libxbpps: when fetching new pkg-index.plist from a repository,
make sure that it's a plist file and can be internalized; otherwise
remove downloaded file and return error.
* xbps-bin(8): new test for the 'check' target to fix missing * xbps-bin(8): new test for the 'check' target to fix missing
entries in requiredby array, i.e reverse dependencies in entries in requiredby array, i.e reverse dependencies in
the package database plist. the package database plist.

View File

@ -89,6 +89,7 @@ xbps_get_remote_repo_string(const char *uri)
int int
xbps_repository_sync_pkg_index(const char *uri) xbps_repository_sync_pkg_index(const char *uri)
{ {
prop_dictionary_t tmpd;
struct xbps_handle *xhp; struct xbps_handle *xhp;
struct url *url = NULL; struct url *url = NULL;
struct utsname un; struct utsname un;
@ -198,6 +199,20 @@ xbps_repository_sync_pkg_index(const char *uri)
} }
if (only_sync) if (only_sync)
goto out; goto out;
/*
* Make sure that downloaded plist file can be internalized, i.e
* some HTTP servers don't return proper errors and sometimes
* you get an HTML ASCII file :-)
*/
tmpd = prop_dictionary_internalize_from_zfile(tmp_metafile);
if (tmpd == NULL) {
xbps_error_printf("[rsyncidx] downloaded pkg-index.plist "
"file cannot be read! removing...\n");
(void)unlink(tmp_metafile);
rv = -1;
goto out;
}
prop_object_release(tmpd);
lrepofile = xbps_xasprintf("%s/%s", lrepodir, XBPS_PKGINDEX); lrepofile = xbps_xasprintf("%s/%s", lrepodir, XBPS_PKGINDEX);
if (lrepofile == NULL) { if (lrepofile == NULL) {