mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
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 <abologna@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
3179220e4f
commit
2bdd654269
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user