From 58423eaf49455377025bd88cc3512fbdda93e987 Mon Sep 17 00:00:00 2001 From: "Steffen (Daode) Nurpmeso" Date: Fri, 23 Sep 2016 01:00:33 +0200 Subject: [PATCH] MLE.bind.a_tty_bind_create(): properly align durable buffer, too (sic) --- tty.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tty.c b/tty.c index 7d694fae..d5df2825 100644 --- a/tty.c +++ b/tty.c @@ -2855,7 +2855,8 @@ a_tty_bind_create(struct a_tty_bind_parse_ctx *tbpcp, bool_t replace){ tbcp = smalloc(sizeof(*tbcp) - VFIELD_SIZEOF(struct a_tty_bind_ctx, tbc__buf) + - tbpcp->tbpc_seq_len + tbpcp->tbpc_exp.l + tbpcp->tbpc_cnv_len +3); + tbpcp->tbpc_seq_len + tbpcp->tbpc_exp.l + + MAX(sizeof(si32_t), sizeof(wc_t)) + tbpcp->tbpc_cnv_len +3); if(tbpcp->tbpc_ltbcp != NULL){ tbcp->tbc_next = tbpcp->tbpc_ltbcp->tbc_next; tbpcp->tbpc_ltbcp->tbc_next = tbcp; @@ -2869,7 +2870,10 @@ a_tty_bind_create(struct a_tty_bind_parse_ctx *tbpcp, bool_t replace){ tbpcp->tbpc_seq, i = (tbcp->tbc_seq_len = tbpcp->tbpc_seq_len) +1); memcpy(tbcp->tbc_exp = &tbcp->tbc__buf[i], tbpcp->tbpc_exp.s, j = (tbcp->tbc_exp_len = tbpcp->tbpc_exp.l) +1); - memcpy(tbcp->tbc_cnv = &tbcp->tbc__buf[i += j], + i += j; + i = ((i + (MAX(sizeof(si32_t), sizeof(wc_t)) - 1)) & + ~(MAX(sizeof(si32_t), sizeof(wc_t)) - 1)); + memcpy(tbcp->tbc_cnv = &tbcp->tbc__buf[i], tbpcp->tbpc_cnv, (tbcp->tbc_cnv_len = tbpcp->tbpc_cnv_len) +1); tbcp->tbc_flags = tbpcp->tbpc_flags; } -- 2.11.4.GIT