[libvirt PATCH] remote: Avoid crash in remoteSplitURIScheme()

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

 



We need to make sure the URI scheme is present before passing
it to strchr(), otherwise we're going to get

  $ virt-ssh-helper foo
  Segmentation fault (core dumped)

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 src/remote/remote_sockets.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/remote/remote_sockets.c b/src/remote/remote_sockets.c
index 2979576680..c315b24d30 100644
--- a/src/remote/remote_sockets.c
+++ b/src/remote/remote_sockets.c
@@ -69,7 +69,15 @@ remoteSplitURIScheme(virURI *uri,
                      char **driver,
                      remoteDriverTransport *transport)
 {
-    char *p = strchr(uri->scheme, '+');
+    char *p = NULL;
+
+    if (!uri->scheme) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("missing scheme for URI"));
+        return -1;
+    }
+
+    p = strchr(uri->scheme, '+');
 
     if (p)
         *driver = g_strndup(uri->scheme, p - uri->scheme);
-- 
2.31.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