[PATCH 2/3] xen: Check return value of virStringReplace

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

 



After 6604a3dd9f8 in which new helper function has been
introduced, the code calls virStringReplace and dereference the
result immediately. The string function can, however, return NULL
so this would SIGSEGV right away. Check for the return value of
the string function.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/xenconfig/xen_xl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 585ef9b..e65f5c6 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -254,7 +254,12 @@ xenParseXLDiskSrc(virDomainDiskDefPtr disk, char *srcstr)
     int ret = -1;
 
     if (STRPREFIX(srcstr, "rbd:")) {
-        tmpstr = virStringReplace(srcstr, "\\\\", "\\");
+        if (!(tmpstr = virStringReplace(srcstr, "\\\\", "\\"))) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("Unable to parse disk source string: %s"),
+                           srcstr);
+            goto cleanup;
+        }
 
         virDomainDiskSetType(disk, VIR_STORAGE_TYPE_NETWORK);
         disk->src->protocol = VIR_STORAGE_NET_PROTOCOL_RBD;
-- 
2.4.10

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]