summaryrefslogtreecommitdiff
path: root/lib/verify.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2016-10-27 14:44:37 +0300
committerPanu Matilainen <pmatilai@redhat.com>2016-10-27 14:46:44 +0300
commit0afc0017fbac237216d40abb086fd78d3e800e6f (patch)
tree010cccf78550715a90f59226f818a1086daad48f /lib/verify.c
parentbfc63b6c3b28a56c9a494567ad6d3adb5b429f34 (diff)
downloadrpm-0afc0017fbac237216d40abb086fd78d3e800e6f.tar.gz
Don't adjust stat file size on rpmDoDigest() failure when verifying
The size is likely to be wrong anyhow but if we can't read the file then any correction is likely to be more wrong than the original value. While at it, eliminate an unnecessary function-level temporary variable used for this one purpose only.
Diffstat (limited to 'lib/verify.c')
-rw-r--r--lib/verify.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/verify.c b/lib/verify.c
index 2ac7c0844..dd97956da 100644
--- a/lib/verify.c
+++ b/lib/verify.c
@@ -61,7 +61,6 @@ int rpmVerifyFile(const rpmts ts, const rpmfi fi,
rpmVerifyAttrs flags = rpmfiVFlags(fi);
const char * fn = rpmfiFN(fi);
struct stat sb;
- int rc;
*res = RPMVERIFY_NONE;
@@ -132,12 +131,12 @@ int rpmVerifyFile(const rpmts ts, const rpmfi fi,
unsigned char fdigest[diglen];
rpm_loff_t fsize;
- rc = rpmDoDigest(algo, fn, 0, fdigest, &fsize);
- sb.st_size = fsize;
- if (rc) {
+ if (rpmDoDigest(algo, fn, 0, fdigest, &fsize)) {
*res |= (RPMVERIFY_READFAIL|RPMVERIFY_FILEDIGEST);
- } else if (memcmp(fdigest, digest, diglen)) {
- *res |= RPMVERIFY_FILEDIGEST;
+ } else {
+ sb.st_size = fsize;
+ if (memcmp(fdigest, digest, diglen))
+ *res |= RPMVERIFY_FILEDIGEST;
}
} else {
*res |= RPMVERIFY_FILEDIGEST;