unpack: make sure to use exact file when checking for hash matches.

This commit is contained in:
Juan RP 2012-06-05 20:23:12 +02:00
parent 84c6850c28
commit a00a450fe0
2 changed files with 11 additions and 3 deletions

View File

@ -56,7 +56,7 @@
*/ */
#define XBPS_PKGINDEX_VERSION "1.5" #define XBPS_PKGINDEX_VERSION "1.5"
#define XBPS_API_VERSION "20120605" #define XBPS_API_VERSION "20120605-1"
#define XBPS_VERSION "0.16" #define XBPS_VERSION "0.16"
/** /**

View File

@ -164,6 +164,7 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
size_t nmetadata = 0, entry_idx = 0; size_t nmetadata = 0, entry_idx = 0;
const char *entry_pname, *transact, *pkgname, *version, *pkgver, *fname; const char *entry_pname, *transact, *pkgname, *version, *pkgver, *fname;
char *buf = NULL, *pkgfilesd = NULL; char *buf = NULL, *pkgfilesd = NULL;
size_t i, x;
int ar_rv, rv, flags; int ar_rv, rv, flags;
bool preserve, update, conf_file, file_exists, skip_obsoletes; bool preserve, update, conf_file, file_exists, skip_obsoletes;
bool softreplace; bool softreplace;
@ -371,10 +372,17 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
if (xbps_entry_is_a_conf_file(propsd, entry_pname)) if (xbps_entry_is_a_conf_file(propsd, entry_pname))
conf_file = true; conf_file = true;
if (stat(entry_pname, &st) == 0) { if (stat(entry_pname, &st) == 0) {
/* remove first char, i.e '.' */
buf = strdup(entry_pname);
assert(buf != NULL);
for (i = 1, x = 0; i < strlen(entry_pname); x++, i++)
buf[x] = entry_pname[i];
buf[x] = '\0';
file_exists = true; file_exists = true;
rv = xbps_file_hash_check_dictionary(filesd, rv = xbps_file_hash_check_dictionary(filesd,
conf_file ? "conf_files" : "files", conf_file ? "conf_files" : "files", buf);
entry_pname); free(buf);
if (rv == -1) { if (rv == -1) {
/* error */ /* error */
xbps_dbg_printf("%s-%s: failed to check" xbps_dbg_printf("%s-%s: failed to check"