On Sat, Nov 02, 2019 at 01:28:51AM -0300, jcfaracco@xxxxxxxxx wrote:
From: Julio Faracco <jcfaracco@xxxxxxxxx> In function virSecurityDeviceLabelDefNew(), when libvirt fails to allocate seclabel structure it returns a failure. This case is setting seclabel as a NULL pointer and accessing its attribute below. This commit fixes this wrong logic.
As of [0]: commit 52117fa97e46d27718eaeb92534a0f5800c326ef Author: Daniel P. Berrangé <berrange@xxxxxxxxxx> CommitDate: 2019-09-13 10:05:17 +0100 util: make allocation functions abort on OOM libvirt's allocation functions never fail. This change was made to allow usage of GLib allocation functions, which also abort on OOM.
Signed-off-by: Julio Faracco <jcfaracco@xxxxxxxxx> --- src/util/virseclabel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virseclabel.c b/src/util/virseclabel.c index a2b5ebf6b7..2141d84210 100644 --- a/src/util/virseclabel.c +++ b/src/util/virseclabel.c @@ -77,7 +77,7 @@ virSecurityDeviceLabelDefNew(const char *model) if (VIR_ALLOC(seclabel) < 0) {
So everything inside this if is dead code waiting to be cleaned up. See: https://libvirt.org/hacking.html#glib for the GLib equivalents of functions for allocation. Jano
virSecurityDeviceLabelDefFree(seclabel); - seclabel = NULL; + return NULL; } seclabel->model = g_strdup(model); -- 2.20.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list
[0] https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=52117fa97e46d
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list