mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2026-01-10 23:57:46 +00:00
Do not crash so easily when given invalid uri
'remote-viewer foobar' shouldn't crash
This commit is contained in:
parent
cf5082577a
commit
e06c822023
@ -730,7 +730,7 @@ remote_viewer_start(VirtViewerApp *app)
|
||||
DEBUG_LOG("Opening display to %s", guri);
|
||||
g_object_set(app, "title", guri, NULL);
|
||||
|
||||
if (virt_viewer_util_extract_host(guri, &type, NULL, NULL, NULL, NULL) < 0) {
|
||||
if (virt_viewer_util_extract_host(guri, &type, NULL, NULL, NULL, NULL) < 0 || type == NULL) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Cannot determine the connection type from URI"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -669,6 +669,7 @@ virt_viewer_app_create_session(VirtViewerApp *self, const gchar *type)
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_APP(self), -1);
|
||||
VirtViewerAppPrivate *priv = self->priv;
|
||||
g_return_val_if_fail(priv->session == NULL, -1);
|
||||
g_return_val_if_fail(type != NULL, -1);
|
||||
|
||||
#ifdef HAVE_GTK_VNC
|
||||
if (g_ascii_strcasecmp(type, "vnc") == 0) {
|
||||
|
||||
@ -81,7 +81,7 @@ virt_viewer_util_extract_host(const char *uristr,
|
||||
int *port)
|
||||
{
|
||||
xmlURIPtr uri;
|
||||
char *offset;
|
||||
char *offset = NULL;
|
||||
|
||||
if (uristr == NULL ||
|
||||
!g_ascii_strcasecmp(uristr, "xen"))
|
||||
@ -107,16 +107,17 @@ virt_viewer_util_extract_host(const char *uristr,
|
||||
if (port)
|
||||
*port = uri->port;
|
||||
|
||||
offset = strchr(uri->scheme, '+');
|
||||
if (uri->scheme)
|
||||
offset = strchr(uri->scheme, '+');
|
||||
|
||||
if (transport) {
|
||||
if (offset)
|
||||
*transport = g_strdup(offset+1);
|
||||
*transport = g_strdup(offset + 1);
|
||||
else
|
||||
*transport = NULL;
|
||||
}
|
||||
|
||||
if (scheme) {
|
||||
if (scheme && uri->scheme) {
|
||||
if (offset)
|
||||
*scheme = g_strndup(uri->scheme, offset - uri->scheme);
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user