From nobody Tue Dec 16 16:39:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1675869568; cv=none; d=zohomail.com; s=zohoarc; b=jau2S0yAgAgb8ixgxzF6371nivbjq6ZR6NrjTyZ3vstXzxVXxpXo6h9YwO5DF4SNhmAh26KqRWk/JH6OPH9X0STKIOofw3f2GtHBivzbZHTTrXCgfkH6IDfnDfd3Eg4LYnXj5qvFwvyKMxIWK+TCzauLQ+8DtJSjrud78hzEj98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675869568; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QGxq2+lZvuGExahNKnRMsAh1RAMAVDSt9JWbwp2SaY8=; b=HSKPEar+1VBDtvHssu5IFxH2Oglweid0EgPlxYun++Bz86e5zyosjkW6gMwv6joUFhbPGOnMupO9s3lhcc6L2WSFuOjzmXyLzHtrnOFfCXtWsjhVXbSFVhUjyxQsM7h06SlF9x5kNihkMQ4jWuXngJk8xOLxNHjShbaG1uScQ4I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1675869568842237.21840837294894; Wed, 8 Feb 2023 07:19:28 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-53-l4NgeMA9OOyv-WJjv35EFA-1; Wed, 08 Feb 2023 10:19:25 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 60441101A521; Wed, 8 Feb 2023 15:19:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B3E918EC2; Wed, 8 Feb 2023 15:19:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E23AA19465B5; Wed, 8 Feb 2023 15:19:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 635501946589 for ; Wed, 8 Feb 2023 15:19:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 54936492C3E; Wed, 8 Feb 2023 15:19:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.40.23.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF8D2492B00 for ; Wed, 8 Feb 2023 15:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675869567; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QGxq2+lZvuGExahNKnRMsAh1RAMAVDSt9JWbwp2SaY8=; b=gszAlpSKvQTeMWi+csUMb7nJDRq19/xpdEx+6IvGtVd7hA6kaHUFI/RhJKsHIGUCV5++29 73f0uFfZy6dMr3sxqODidFXo8OqHO2oJcyMm/kLcGlSDP8rxG/Vnz/095PEXW3OcoRW6Yp QvS5P3RoP6x+tmtuua3IVJtOvPzsLvg= X-MC-Unique: l4NgeMA9OOyv-WJjv35EFA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 1/8] viruri: Search params case insensitively Date: Wed, 8 Feb 2023 16:19:07 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1675869569196100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Our URI handling code (doRemoteOpen() specifically), uses case insensitive parsing of query part of URI. For instance: qemu:///system?socket=3D/some/path qemu:///system?SoCkEt=3D/some/path are the same URI. Even though the latter is probably not used anywhere, let's switch to STRCASEEQ() instead of STREQ() at two places: virURIGetParam() and virURICheckUnixSocket(). Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/util/viruri.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/util/viruri.c b/src/util/viruri.c index 88bb0cc1f8..4afdd30c59 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -365,13 +365,24 @@ virURIResolveAlias(virConf *conf, const char *alias, = char **uri) } =20 =20 +/** + * virURIGetParam: + * @uri: URI to get parameter from + * @name: name of the parameter + * + * For parsed @uri, find parameter with name @name and return its value. T= he + * string comparison is case insensitive, by design. + * + * Returns: a value on success, or + * NULL on error (with error reported) + */ const char * virURIGetParam(virURI *uri, const char *name) { size_t i; =20 for (i =3D 0; i < uri->paramsCount; i++) { - if (STREQ(uri->params[i].name, name)) + if (STRCASEEQ(uri->params[i].name, name)) return uri->params[i].value; } =20 @@ -389,6 +400,8 @@ virURIGetParam(virURI *uri, const char *name) * scenario the socket might be proxied to a remote server even though the= URI * looks like it is only local. * + * The "socket" parameter is looked for in case insensitive manner, by des= ign. + * * Returns: true if the URI might be proxied to a remote server */ bool @@ -403,7 +416,7 @@ virURICheckUnixSocket(virURI *uri) return false; =20 for (i =3D 0; i < uri->paramsCount; i++) { - if (STREQ(uri->params[i].name, "socket")) + if (STRCASEEQ(uri->params[i].name, "socket")) return true; } =20 --=20 2.39.1