From 69a06a1fde0b169165db987075a736983f9fa06d 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 (cherry picked from commit 31375ca349c27289d1cc3fb9f78efa8ca99127cb) (cherry picked from commit 7cc36dd28ec61a58d08e2bc5108127c7ef93f30c) --- daemon/bencode.c | 4 +--- include/bencode.h | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/daemon/bencode.c b/daemon/bencode.c index 0683c213a..fc5638d69 100644 --- a/daemon/bencode.c +++ b/daemon/bencode.c @@ -16,13 +16,11 @@ #define BENCODE_HASH_BUCKETS 31 /* prime numbers work best */ -#define BENCODE_ALLOC_ALIGN 8 - struct __bencode_buffer_piece { char *tail; unsigned int left; struct __bencode_buffer_piece *next; - char buf[0]; + char buf[0] __attribute__ ((aligned (BENCODE_ALLOC_ALIGN))); }; struct __bencode_free_list { void *ptr; diff --git a/include/bencode.h b/include/bencode.h index 30f448412..ca8d85f6c 100644 --- a/include/bencode.h +++ b/include/bencode.h @@ -7,6 +7,8 @@ #include "compat.h" +#define BENCODE_ALLOC_ALIGN 8 + struct bencode_buffer; enum bencode_type; struct bencode_item; @@ -35,7 +37,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 {