From 84c6850c284d6f62f4fd2dcc24dfe2b966706fea Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 5 Jun 2012 20:22:47 +0200 Subject: [PATCH] xbps_file_hash_dictionary: only process exact matches. --- lib/util_hash.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/util_hash.c b/lib/util_hash.c index 8a20c27a..e89742fc 100644 --- a/lib/util_hash.c +++ b/lib/util_hash.c @@ -159,12 +159,12 @@ xbps_file_hash_dictionary(prop_dictionary_t d, while ((obj = prop_object_iterator_next(iter)) != NULL) { prop_dictionary_get_cstring_nocopy(obj, "file", &curfile); - if (strstr(file, curfile) == NULL) - continue; - /* file matched */ - prop_dictionary_get_cstring_nocopy(obj, - "sha256", &sha256); - break; + if (strcmp(file, curfile) == 0) { + /* file matched */ + prop_dictionary_get_cstring_nocopy(obj, + "sha256", &sha256); + break; + } } prop_object_iterator_release(iter); if (sha256 == NULL) @@ -193,8 +193,7 @@ xbps_file_hash_check_dictionary(prop_dictionary_t d, return -1; /* error */ } - rv = xbps_file_hash_check(file, sha256d); - if (rv == 0) + if ((rv = xbps_file_hash_check(file, sha256d)) == 0) return 0; /* matched */ else if (rv == ERANGE || rv == ENOENT) return 1; /* no match */