[libvirt PATCH] remote: Avoid crash in remoteSplitURIScheme()
Peter Krempa
pkrempa at redhat.com
Fri Dec 10 10:31:19 UTC 2021
On Fri, Dec 10, 2021 at 10:59:27 +0100, Andrea Bolognani wrote:
> 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 at redhat.com>
> ---
> 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"));
The other place which leads to the call of this helper (virConnectOpenInternal)
uses the following error to reject the uri if scheme is missing:
virReportError(VIR_ERR_NO_CONNECT,
_("URI '%s' does not include a driver name"),
name);
It looks like it's unlikely that anybody would use virt-ssh-helper
manually though.
Reviewed-by: Peter Krempa <pkrempa at redhat.com>
More information about the libvir-list
mailing list