From: Andrea Bolognani Date: Fri, 10 Dec 2021 09:54:54 +0000 (+0100) Subject: remote: Avoid crash in remoteSplitURIScheme() X-Git-Tag: v8.0.0-rc1~330 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bdd654269a2febf306ec840b72daf46336c9421;p=thirdparty%2Flibvirt.git remote: Avoid crash in remoteSplitURIScheme() 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 Reviewed-by: Peter Krempa --- 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);