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@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
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);