From 93f3467dcfe1601bb70547611866a069ae914de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Mon, 22 Sep 2025 10:48:24 +0000 Subject: [PATCH] iobuffer: Fix encoding/decoding on big-endian MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is possible (albeit unusual) to boot a big-endian system on a smartphone, and it's generally good to have portable code. le32toh and htole32 are a glibc extension that is also implemented by musl-libc, uclibc-ng, and bionic. Signed-off-by: J. Neuschäfer --- hexagonrpcd/iobuffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hexagonrpcd/iobuffer.c b/hexagonrpcd/iobuffer.c index 6481651..1064378 100644 --- a/hexagonrpcd/iobuffer.c +++ b/hexagonrpcd/iobuffer.c @@ -39,6 +39,9 @@ static size_t consume_size(struct fastrpc_decoder_context *ctx, ctx->size_off = (ctx->size_off + segment) % 4; ctx->align = (ctx->align + segment) & 0x7; + if (ctx->size_off == 0) + ctx->size = le32toh(ctx->size); + return segment; } @@ -212,7 +215,7 @@ void outbufs_encode(size_t n_outbufs, const struct fastrpc_io_buffer *outbufs, size_t i; for (i = 0; i < n_outbufs; i++) { - *(uint32_t *) ptr = outbufs[i].s; + *(uint32_t *) ptr = htole32(outbufs[i].s); ptr = &ptr[4]; align = (align + 4) & 0x7;