From 34ab0b7c777d39fcaadbf2c92782cd755b50a50c Mon Sep 17 00:00:00 2001 From: "Roland C. Dowdeswell" Date: Wed, 10 Jun 2026 13:19:51 +0100 Subject: [PATCH] asn1: fix open type alignment on ILP32 Do not assume that the open-type payload needs 8-byte alignment. Align to pointer size instead, which avoids reading the wrong location on ILP32 layouts. --- lib/asn1/template.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/asn1/template.c b/lib/asn1/template.c index 86b67c373..4b2caab98 100644 --- a/lib/asn1/template.c +++ b/lib/asn1/template.c @@ -2489,8 +2489,10 @@ _asn1_print_open_type(const struct asn1_template *t, /* object set template */ } if (!(t->tt & A1_OS_OT_IS_ARRAY)) { - unsigned align = 8 - ((t->offset + sizeof(*elementp)) & 0x7); - dp = DPOC(data, t->offset + sizeof(*elementp) + align); + size_t offset = t->offset + sizeof(*elementp); + + offset += (sizeof(void *) - offset % sizeof(void *)) % sizeof(void *); + dp = DPOC(data, offset); if (*dp) { struct rk_strpool *r2 = NULL; char *s = NULL;