libs/guest: Reduce number of iovecs in write_split_record()

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 <frediano.ziglio@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Anthony PERARD <anthony.perard@vates.tech>
This commit is contained in:
Frediano Ziglio authored and Andrew Cooper committed 2026-07-08 15:35:45 +01:00
1 parent 42ef7f6106
commit 32204e8e19
1 file changed
+3 -3
+3 -3
View File
@@ -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 },
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.