]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Prevent unaligned double word access on ARMv7 in put_uint64
authorNiLuJe <ninuje@gmail.com>
Sun, 2 Aug 2020 18:22:04 +0000 (20:22 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 20 Aug 2020 10:04:56 +0000 (12:04 +0200)
By implementing a (UNALIGNED_OK && !UNALIGNED64_OK) codepath.

deflate.h

index 600fca6d246cab1084a884ddbd9e56dee6447705..ce6106cffa312ffe107499b2cf93d75cd399515d 100644 (file)
--- a/deflate.h
+++ b/deflate.h
@@ -351,9 +351,14 @@ static inline void put_uint32_msb(deflate_state *s, uint32_t dw) {
  * IN assertion: there is enough room in pending_buf.
  */
 static inline void put_uint64(deflate_state *s, uint64_t lld) {
-#if defined(UNALIGNED_OK)
+#if defined(UNALIGNED64_OK)
     *(uint64_t *)(&s->pending_buf[s->pending]) = lld;
     s->pending += 8;
+#elif defined(UNALIGNED_OK)
+    *(uint32_t *)(&s->pending_buf[s->pending]) = lld & 0xffffffff;
+    s->pending += 4;
+    *(uint32_t *)(&s->pending_buf[s->pending]) = (lld >> 32) & 0xffffffff;
+    s->pending += 4;
 #else
     put_byte(s, (lld & 0xff));
     put_byte(s, ((lld >> 8) & 0xff));