]> xenbits.xensource.com Git - libvirt.git/commitdiff
esx: Fix nodeGetInfo so cpu model fits inside nodeinfo->model
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>
Sun, 12 Aug 2018 11:05:19 +0000 (08:05 -0300)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 13 Aug 2018 14:03:18 +0000 (16:03 +0200)
Commit 6c0d0210cbcd5d647f0d882c07f077d444bc707d changed the behavior of
virStr*cpy* functions, so now the nodeGetInfo call fails. Version 4.1.0
(default for Fedora 28) works:

Model: Intel Core i7-4500U CPU @ 1.80G

Current master tries to write "Intel Core i7-4500U CPU @ 1.80GHz", but
the string is bigger than nodeinfo->model (which is a char[32]). So this
patch "cuts" the string, and presents the same output from 4.1.0.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
src/esx/esx_driver.c

index c2154799fae2f87a993c92f7d4ca9959b509192c..03a84d76301296d1f570ba11f5405905406acd78 100644 (file)
@@ -1317,6 +1317,8 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo)
                 ++ptr;
             }
 
+            /* Make sure the string fits in mode */
+            dynamicProperty->val->string[sizeof(nodeinfo->model) - 1] = '\0';
             if (virStrcpyStatic(nodeinfo->model, dynamicProperty->val->string) < 0) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("CPU Model %s too long for destination"),