[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [qemu-xen staging] s390x/s390-virtio-ccw: fix loadparm property getter
commit d6645483285feaa0aa26fe2b0c3bac6989250d2f Author: Halil Pasic <pasic@xxxxxxxxxxxxx> AuthorDate: Thu Jul 23 18:27:17 2020 +0200 Commit: Cornelia Huck <cohuck@xxxxxxxxxx> CommitDate: Fri Jul 24 08:49:53 2020 +0200 s390x/s390-virtio-ccw: fix loadparm property getter The function machine_get_loadparm() is supposed to produce a C-string, that is a NUL-terminated one, but it does not. ElectricFence can detect this problem if the loadparm machine property is used. Let us make the returned string a NUL-terminated one. Fixes: 7104bae9de ("hw/s390x: provide loadparm property for the machine") Signed-off-by: Halil Pasic <pasic@xxxxxxxxxxxxx> Reviewed-by: Thomas Huth <thuth@xxxxxxxxxx> Message-Id: <20200723162717.88485-1-pasic@xxxxxxxxxxxxx> Signed-off-by: Cornelia Huck <cohuck@xxxxxxxxxx> --- hw/s390x/s390-virtio-ccw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 8cc2f25d8a..403d30e13b 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -701,8 +701,12 @@ bool hpage_1m_allowed(void) static char *machine_get_loadparm(Object *obj, Error **errp) { S390CcwMachineState *ms = S390_CCW_MACHINE(obj); + char *loadparm_str; - return g_memdup(ms->loadparm, sizeof(ms->loadparm)); + /* make a NUL-terminated string */ + loadparm_str = g_memdup(ms->loadparm, sizeof(ms->loadparm) + 1); + loadparm_str[sizeof(ms->loadparm)] = 0; + return loadparm_str; } static void machine_set_loadparm(Object *obj, const char *val, Error **errp) -- generated by git-patchbot for /home/xen/git/qemu-xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |