From nobody Mon May 6 12:03:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639130379; cv=none; d=zohomail.com; s=zohoarc; b=VSjJ2zH5EN++84LfGb+PQa0Rr4a+Swamy/SGi5cvNAFgKFZyJfX46kGJ8xo0+3SHgfTOVQPh2CJmSksUaWBQffpFiEkuV+PKLVThIhBr0BuZpO8D4GdUCGfTgXgUlEz9V/nSABHOTe1sEKWULTuJz0LHNDPyzSXpdH4xDTGomWw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639130379; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=nziNTfSzYSvX7XJtHTMTVaVQqX6pVVWAve+nWW8kb50=; b=SVZIeMlUImpxX60Vyt5oznLA30yOoY2v0+SRdUkDmNueR/PxKJzoojM8JCRn6RwMKJVxqDYfAzjerawtNEV5EZmmz/PyAqakkueUdquZIXc0QK/vtcez7VM4d0CgdBL357nd/FGRe9ynd1VLoQayQo7iOjAWrzaB3crGJsMYXsY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639130379358768.2484610552665; Fri, 10 Dec 2021 01:59:39 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-446-7qjTvlDgPvqrtw0AmEQsbg-1; Fri, 10 Dec 2021 04:59:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 597341017965; Fri, 10 Dec 2021 09:59:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D32360C82; Fri, 10 Dec 2021 09:59:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 10A464A7C9; Fri, 10 Dec 2021 09:59:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BA9xVwg008663 for ; Fri, 10 Dec 2021 04:59:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 05B415ED2B; Fri, 10 Dec 2021 09:59:31 +0000 (UTC) Received: from kinshicho.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5BE0F5D9D5 for ; Fri, 10 Dec 2021 09:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639130378; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nziNTfSzYSvX7XJtHTMTVaVQqX6pVVWAve+nWW8kb50=; b=NF2OGzCLpL0T3Suxp5yVjaz6gC8UNi0108py2DzEmjgNsNSmT04XGeM11B/LUBRlO2TWWc 1LrYoC6yWP01PHbnRFxwlD0exg5j76l+rhX6/4yOsDhHk0XfMTZhShsK9PzcaxlWlvy4sR 1gVdWR9leaZN7ydHrRE3SZfQuHnMYuM= X-MC-Unique: 7qjTvlDgPvqrtw0AmEQsbg-1 From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH] remote: Avoid crash in remoteSplitURIScheme() Date: Fri, 10 Dec 2021 10:59:27 +0100 Message-Id: <20211210095927.304135-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639130380608100001 Content-Type: text/plain; charset="utf-8" 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 --- 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 =3D strchr(uri->scheme, '+'); + char *p =3D NULL; + + if (!uri->scheme) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing scheme for URI")); + return -1; + } + + p =3D strchr(uri->scheme, '+'); =20 if (p) *driver =3D g_strndup(uri->scheme, p - uri->scheme); --=20 2.31.1