mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
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:
1 parent
42ef7f6106
commit
32204e8e19
1 file changed
+3
-3
@@ -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 },
|
||||
|
||||