From 31375ca349c27289d1cc3fb9f78efa8ca99127cb Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 27 May 2026 08:59:55 -0400 Subject: [PATCH] MT#55283 fix bencode buffer alignment Make sure data is 64-bit aligned. Fixes alignment issues on certain 32-bit archs (armhf). Change-Id: I66c1fc20e97c62d3d5e266e874812aed74d295ed --- lib/bencode.c | 4 +--- lib/bencode.h | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/bencode.c b/lib/bencode.c index 3cb403e1f..1bc003bf0 100644 --- a/lib/bencode.c +++ b/lib/bencode.c @@ -15,13 +15,11 @@ #define BENCODE_HASH_BUCKETS 31 /* prime numbers work best */ -#define BENCODE_ALLOC_ALIGN 8 - struct __bencode_buffer_piece { char *tail; size_t left; struct __bencode_buffer_piece *next; - char buf[0]; + char buf[0] __attribute__ ((aligned (BENCODE_ALLOC_ALIGN))); }; struct __bencode_hash { struct bencode_item *buckets[BENCODE_HASH_BUCKETS]; diff --git a/lib/bencode.h b/lib/bencode.h index 9bee7a1dd..7129af791 100644 --- a/lib/bencode.h +++ b/lib/bencode.h @@ -6,6 +6,8 @@ #include "compat.h" +#define BENCODE_ALLOC_ALIGN 8 + struct bencode_buffer; enum bencode_type; struct bencode_item; @@ -34,7 +36,7 @@ struct bencode_item { long long int value; /* when decoding an integer, contains the value; otherwise used internally */ bencode_item_t *parent, *child, *last_child, *sibling; bencode_buffer_t *buffer; - char __buf[0]; + char __buf[0] __attribute__ ((aligned (BENCODE_ALLOC_ALIGN))); }; struct bencode_buffer {