[gcab] trivial: Print the desired checksum when not enforcing
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcab] trivial: Print the desired checksum when not enforcing
- Date: Mon, 18 Dec 2017 13:56:21 +0000 (UTC)
commit 2858d98126deb4c8c3d2d18bc0f63395e2c6c00b
Author: Richard Hughes <richard hughsie com>
Date: Mon Dec 18 12:24:02 2017 +0000
trivial: Print the desired checksum when not enforcing
libgcab/cabinet.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/libgcab/cabinet.c b/libgcab/cabinet.c
index 96f821d..b5b44cd 100644
--- a/libgcab/cabinet.c
+++ b/libgcab/cabinet.c
@@ -532,6 +532,7 @@ cdata_read (cdata_t *cd, guint8 res_data, gint comptype,
gint compression = comptype & GCAB_COMPRESSION_MASK;
guint8 *buf = compression == GCAB_COMPRESSION_NONE ? cd->out : cd->in;
guint32 datacsum;
+ guint32 checksum_tmp;
guint8 sizecsum[4];
guint16 nbytes_le;
@@ -554,10 +555,15 @@ cdata_read (cdata_t *cd, guint8 res_data, gint comptype,
memcpy (&sizecsum[0], &nbytes_le, 2);
nbytes_le = GUINT16_TO_LE (cd->nubytes);
memcpy (&sizecsum[2], &nbytes_le, 2);
- if (_enforce_checksum () && cd->checksum != compute_checksum (sizecsum, sizeof(sizecsum), datacsum)) {
- g_set_error_literal (error, GCAB_ERROR, GCAB_ERROR_INVALID_DATA,
- "incorrect checksum detected");
- return FALSE;
+ checksum_tmp = compute_checksum (sizecsum, sizeof(sizecsum), datacsum);
+ if (cd->checksum != checksum_tmp) {
+ if (_enforce_checksum ()) {
+ g_set_error_literal (error, GCAB_ERROR, GCAB_ERROR_INVALID_DATA,
+ "incorrect checksum detected");
+ return FALSE;
+ }
+ if (g_getenv ("GCAB_DEBUG"))
+ g_debug ("CDATA checksum 0x%08x", (guint) checksum_tmp);
}
if (g_getenv ("GCAB_DEBUG")) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]