[libvirt] [PATCH] selinux: fix NULL dereference in GetSecurityMountOptions

In the case of an OOM error in virDomainDefGetSecurityLabelDef, secdef is set to NULL, then dereferenced while printing the debug message. --- src/security/security_selinux.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 5409e32..9134bc8 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1993,7 +1993,8 @@ virSecuritySELinuxGetSecurityMountOptions(virSecurityManagerPtr mgr, return NULL; } - VIR_DEBUG("imageLabel=%s opts=%s", secdef->imagelabel, opts); + VIR_DEBUG("imageLabel=%s opts=%s", + secdef ? secdef->imagelabel : "(null)", opts); return opts; } -- 1.7.8.6

On Thu, Dec 13, 2012 at 11:44:37AM +0100, Ján Tomko wrote:
In the case of an OOM error in virDomainDefGetSecurityLabelDef, secdef is set to NULL, then dereferenced while printing the debug message. --- src/security/security_selinux.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 5409e32..9134bc8 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1993,7 +1993,8 @@ virSecuritySELinuxGetSecurityMountOptions(virSecurityManagerPtr mgr, return NULL; }
- VIR_DEBUG("imageLabel=%s opts=%s", secdef->imagelabel, opts); + VIR_DEBUG("imageLabel=%s opts=%s", + secdef ? secdef->imagelabel : "(null)", opts); return opts; }
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 12/13/2012 03:53 AM, Daniel P. Berrange wrote:
On Thu, Dec 13, 2012 at 11:44:37AM +0100, Ján Tomko wrote:
In the case of an OOM error in virDomainDefGetSecurityLabelDef, secdef is set to NULL, then dereferenced while printing the debug message. --- src/security/security_selinux.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 5409e32..9134bc8 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1993,7 +1993,8 @@ virSecuritySELinuxGetSecurityMountOptions(virSecurityManagerPtr mgr, return NULL; }
- VIR_DEBUG("imageLabel=%s opts=%s", secdef->imagelabel, opts); + VIR_DEBUG("imageLabel=%s opts=%s", + secdef ? secdef->imagelabel : "(null)", opts); return opts; }
ACK
Now pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Ján Tomko