From bd1728e9699c45187d2f16a9c88ba36f9da252ff Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 2 Mar 2021 13:41:22 +0100 Subject: [PATCH] xenParseXLChannel: Use g_strndup instead of virStrncpy MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Make the temporary string an autofree-ing pointer and copy the contents. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/libxl/xen_xl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 4113be8cd1..9b2a2fe292 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1070,7 +1070,7 @@ xenParseXLChannel(virConfPtr conf, virDomainDefPtr def) if (list && list->type == VIR_CONF_LIST) { list = list->list; while (list) { - char type[10]; + g_autofree char *type = NULL; char *key; if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) @@ -1087,11 +1087,8 @@ xenParseXLChannel(virConfPtr conf, virDomainDefPtr def) if (STRPREFIX(key, "connection=")) { int len = nextkey ? (nextkey - data) : strlen(data); - if (virStrncpy(type, data, len, sizeof(type)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("connection %s too big"), data); - goto skipchannel; - } + g_clear_pointer(&type, g_free); + type = g_strndup(data, len); } else if (STRPREFIX(key, "name=")) { int len = nextkey ? (nextkey - data) : strlen(data); VIR_FREE(name); -- 2.47.2