[gcab/wip/hughsie/meson] f
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcab/wip/hughsie/meson] f
- Date: Tue, 12 Dec 2017 14:04:01 +0000 (UTC)
commit caa4fd58aa5c308eee541a2e822e6e6833658dfc
Author: Richard Hughes <richard hughsie com>
Date: Tue Dec 12 14:03:40 2017 +0000
f
libgcab/cabinet.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/libgcab/cabinet.c b/libgcab/cabinet.c
index fd99761..8c944d0 100644
--- a/libgcab/cabinet.c
+++ b/libgcab/cabinet.c
@@ -422,9 +422,12 @@ cdata_write (cdata_t *cd, GDataOutputStream *out, int type,
guint32 datacsum = compute_checksum(cd->in, cd->ncbytes, 0);
guint8 sizecsum[4];
+ guint16 nbytes_le;
- memcpy (&sizecsum[0], &cd->ncbytes, 2);
- memcpy (&sizecsum[2], &cd->nubytes, 2);
+ nbytes_le = GUINT16_TO_LE (cd->ncbytes);
+ memcpy (&sizecsum[0], &nbytes_le, 2);
+ nbytes_le = GUINT16_TO_LE (cd->nubytes);
+ memcpy (&sizecsum[2], &nbytes_le, 2);
cd->checksum = compute_checksum (sizecsum, sizeof(sizecsum), datacsum);
GOutputStream *stream = g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (out));
@@ -469,6 +472,7 @@ cdata_read (cdata_t *cd, guint8 res_data, gint comptype,
guint8 *buf = compression == GCAB_COMPRESSION_NONE ? cd->out : cd->in;
guint32 datacsum;
guint8 sizecsum[4];
+ guint16 nbytes_le;
if (compression > GCAB_COMPRESSION_MSZIP &&
compression != GCAB_COMPRESSION_LZX) {
@@ -485,8 +489,10 @@ cdata_read (cdata_t *cd, guint8 res_data, gint comptype,
RN (buf, cd->ncbytes);
datacsum = compute_checksum(buf, cd->ncbytes, 0);
- memcpy (&sizecsum[0], &cd->ncbytes, 2);
- memcpy (&sizecsum[2], &cd->nubytes, 2);
+ nbytes_le = GUINT16_TO_LE (cd->ncbytes);
+ memcpy (&sizecsum[0], &nbytes_le, 2);
+ nbytes_le = GUINT16_TO_LE (cd->nubytes);
+ memcpy (&sizecsum[2], &nbytes_le, 2);
if (cd->checksum != compute_checksum (sizecsum, sizeof(sizecsum), datacsum)) {
g_set_error_literal (error, GCAB_ERROR, GCAB_ERROR_FAILED,
_("incorrect checksum detected"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]