[PATCH] util: Prevent a NULl pointer from being accessed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Huang Zijiang <huang.zijiang@xxxxxxxxxx>

virJSONValueObjectGetObject maybe return NULL if the key is
missing or if value is not the correct TYPE, so we have to prevent
a NULl pointer from being accessed.

Signed-off-by: Huang Zijiang <huang.zijiang@xxxxxxxxxx>
Signed-off-by: Yi Wang <wang.yi59@xxxxxxxxxx>
---
 src/util/virstoragefile.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index e46ac99..53224b5 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -3378,6 +3378,11 @@ virStorageSourceParseBackingJSONSheepdog(virStorageSourcePtr src,
     const char *filename;
     const char *vdi = virJSONValueObjectGetString(json, "vdi");
     virJSONValuePtr server = virJSONValueObjectGetObject(json, "server");
+    if (!server) {
+    virReportError(VIR_ERR_INVALID_ARG, "%s",
+                        _("missing server in JSON backing volume definition"));
+         return -1;    
+    }
 
     /* legacy URI based syntax passed via 'filename' option */
     if ((filename = virJSONValueObjectGetString(json, "filename"))) {
-- 
1.9.1






[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux