xbps-rindex/index-clean: handle possible NULL pointer derefs (CID #98685).

This commit is contained in:
Juan RP 2015-07-26 08:06:38 +02:00
parent 7edabe907f
commit 9d70fcd8d0

View File

@ -63,6 +63,8 @@ idx_cleaner_cb(struct xbps_handle *xhp,
* broken or simply unexistent; either way, remove it. * broken or simply unexistent; either way, remove it.
*/ */
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
if (pkgname == NULL)
goto out;
xbps_dictionary_remove(dest, pkgname); xbps_dictionary_remove(dest, pkgname);
free(pkgname); free(pkgname);
printf("index: removed pkg %s\n", pkgver); printf("index: removed pkg %s\n", pkgver);
@ -74,11 +76,14 @@ idx_cleaner_cb(struct xbps_handle *xhp,
"filename-sha256", &sha256); "filename-sha256", &sha256);
if (xbps_file_hash_check(filen, sha256) != 0) { if (xbps_file_hash_check(filen, sha256) != 0) {
pkgname = xbps_pkg_name(pkgver); pkgname = xbps_pkg_name(pkgver);
if (pkgname == NULL)
goto out;
xbps_dictionary_remove(dest, pkgname); xbps_dictionary_remove(dest, pkgname);
free(pkgname); free(pkgname);
printf("index: removed pkg %s\n", pkgver); printf("index: removed pkg %s\n", pkgver);
} }
} }
out:
free(filen); free(filen);
return 0; return 0;
} }