From 32204e8e194bfe991fd9d3dd57cdc44663da9f3b Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Fri, 19 Jun 2026 14:04:46 +0100 Subject: [PATCH] libs/guest: Reduce number of iovecs in write_split_record() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Construct xc_sr_rhdr directly rather than in two halves. Use size_t for combined_len, which allows the later size check to spot a few more cases which might have truncated. Signed-off-by: Frediano Ziglio Reviewed-by: Roger Pau Monné Reviewed-by: Andrew Cooper Acked-by: Anthony PERARD --- tools/libs/guest/xg_sr_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/libs/guest/xg_sr_common.c b/tools/libs/guest/xg_sr_common.c index c7b3c6f3bc..9b2782b5cf 100644 --- a/tools/libs/guest/xg_sr_common.c +++ b/tools/libs/guest/xg_sr_common.c @@ -59,11 +59,11 @@ int write_split_record(struct xc_sr_context *ctx, struct xc_sr_record *rec, static const char zeroes[REC_ALIGN] = {}; xc_interface *xch = ctx->xch; - typeof(rec->length) combined_length = rec->length + sz; + size_t combined_length = rec->length + sz; size_t record_length = ROUNDUP(combined_length, REC_ALIGN); + struct xc_sr_rhdr rhdr = { rec->type, combined_length }; struct iovec parts[] = { - { &rec->type, sizeof(rec->type) }, - { &combined_length, sizeof(combined_length) }, + { &rhdr, sizeof(rhdr) }, { rec->data, rec->length }, { buf, sz }, { (void *)zeroes, record_length - combined_length },