From 40e93479999a9c6e227340fdb5ffa877292294bf Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 1 Jul 2026 14:10:46 +0200 Subject: [PATCH] libxc: adjust string size calculations in xc_flask_{getbool_byname,setbool}() In preparation for a hypervisor change also include the nul terminator in the size calculations. (Note that xc_flask_getbool_byid() doesn't support FLASK_GETBOOL's "ID being -1" variant of operation, and hence doesn't need fiddling with. Signed-off-by: Jan Beulich Reviewed-by: Juergen Gross Reviewed-by: Teddy Astie Acked-by: Anthony PERARD --- tools/libs/ctrl/xc_flask.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/libs/ctrl/xc_flask.c b/tools/libs/ctrl/xc_flask.c index 21ba697ad6..f5389dbd96 100644 --- a/tools/libs/ctrl/xc_flask.c +++ b/tools/libs/ctrl/xc_flask.c @@ -186,7 +186,8 @@ int xc_flask_getbool_byname(xc_interface *xch, char *name, int *curr, int *pend) { int rv; struct xen_flask_op op = {}; - DECLARE_HYPERCALL_BOUNCE(name, strlen(name), XC_HYPERCALL_BUFFER_BOUNCE_IN); + size_t size = strlen(name) + 1; + DECLARE_HYPERCALL_BOUNCE(name, size, XC_HYPERCALL_BUFFER_BOUNCE_IN); if ( xc_hypercall_bounce_pre(xch, name) ) { @@ -196,7 +197,7 @@ int xc_flask_getbool_byname(xc_interface *xch, char *name, int *curr, int *pend) op.cmd = FLASK_GETBOOL; op.u.boolean.bool_id = -1; - op.u.boolean.size = strlen(name); + op.u.boolean.size = size; set_xen_guest_handle(op.u.boolean.name, name); rv = xc_flask_op(xch, &op); @@ -218,7 +219,8 @@ int xc_flask_setbool(xc_interface *xch, char *name, int value, int commit) { int rv; struct xen_flask_op op = {}; - DECLARE_HYPERCALL_BOUNCE(name, strlen(name), XC_HYPERCALL_BUFFER_BOUNCE_IN); + size_t size = strlen(name) + 1; + DECLARE_HYPERCALL_BOUNCE(name, size, XC_HYPERCALL_BUFFER_BOUNCE_IN); if ( xc_hypercall_bounce_pre(xch, name) ) { @@ -230,7 +232,7 @@ int xc_flask_setbool(xc_interface *xch, char *name, int value, int commit) op.u.boolean.bool_id = -1; op.u.boolean.new_value = value; op.u.boolean.commit = 1; - op.u.boolean.size = strlen(name); + op.u.boolean.size = size; set_xen_guest_handle(op.u.boolean.name, name); rv = xc_flask_op(xch, &op);