[gnumeric] xls: fix unaligned access.



commit 7b00c724f1215ee4095dfee63b95ff32d25d4576
Author: Morten Welinder <terra gnome org>
Date:   Thu May 14 17:34:11 2015 -0400

    xls: fix unaligned access.

 plugins/excel/ChangeLog |    8 ++++++++
 plugins/excel/md5.c     |   22 ++++++++--------------
 plugins/excel/ms-biff.c |    7 +------
 3 files changed, 17 insertions(+), 20 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 59eb04a..bcfa76f 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,11 @@
+2015-05-14  Morten Welinder  <terra gnome org>
+
+       * md5.c (md5_read_ctx): Don't require aligned memory.
+
+2015-05-13  Morten Welinder  <terra gnome org>
+
+       * ms-excel-read.c (excel_get_text_fixme): Eliminate.
+
 2015-05-12  Morten Welinder  <terra gnome org>
 
        * ms-excel-read.c (excel_read_DV): Stop using
diff --git a/plugins/excel/md5.c b/plugins/excel/md5.c
index ad25f46..419861d 100644
--- a/plugins/excel/md5.c
+++ b/plugins/excel/md5.c
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <glib.h>
+#include <gsf/gsf-utils.h>
 
 #if USE_UNLOCKED_IO
 # include "unlocked-io.h"
@@ -80,26 +81,19 @@ md5_init_ctx (struct md5_ctx *ctx)
 }
 
 /* Put result from CTX in first 16 bytes following RESBUF.  The result
-   must be in little endian byte order.
-
-   IMPORTANT: On some systems it is required that RESBUF is correctly
-   aligned for a 32-bit value.  */
+   will be in little endian byte order. */
 void *
 md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
 {
-  ((uint32_t *) resbuf)[0] = SWAP (ctx->A);
-  ((uint32_t *) resbuf)[1] = SWAP (ctx->B);
-  ((uint32_t *) resbuf)[2] = SWAP (ctx->C);
-  ((uint32_t *) resbuf)[3] = SWAP (ctx->D);
-
-  return resbuf;
+       GSF_LE_SET_GUINT32 ((char *)resbuf + 0x00, ctx->A);
+       GSF_LE_SET_GUINT32 ((char *)resbuf + 0x04, ctx->B);
+       GSF_LE_SET_GUINT32 ((char *)resbuf + 0x08, ctx->C);
+       GSF_LE_SET_GUINT32 ((char *)resbuf + 0x0c, ctx->D);
+       return resbuf;
 }
 
 /* Process the remaining bytes in the internal buffer and the usual
-   prolog according to the standard and write the result to RESBUF.
-
-   IMPORTANT: On some systems it is required that RESBUF is correctly
-   aligned for a 32-bit value.  */
+   prolog according to the standard and write the result to RESBUF.  */
 void *
 md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
 {
diff --git a/plugins/excel/ms-biff.c b/plugins/excel/ms-biff.c
index 470ea85..182bb14 100644
--- a/plugins/excel/ms-biff.c
+++ b/plugins/excel/ms-biff.c
@@ -173,12 +173,7 @@ makekey (guint32 block, RC4_KEY *key, const unsigned char *valDigest)
        /* 40 bit of hashed password, set by verify_password () */
        memcpy (pwarray, valDigest, 5);
 
-       /* put block number in byte 6...9 */
-       pwarray[5] = (guint8) (block & 0xFF);
-       pwarray[6] = (guint8) ((block >> 8) & 0xFF);
-       pwarray[7] = (guint8) ((block >> 16) & 0xFF);
-       pwarray[8] = (guint8) ((block >> 24) & 0xFF);
-
+       GSF_LE_SET_GUINT32 (pwarray + 5, block);
        pwarray[9] = 0x80;
        pwarray[56] = 0x48;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]