From nobody Thu Mar 28 18:54:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1610079035; cv=none; d=zohomail.com; s=zohoarc; b=MQAra0+rsKmQeqlQTMjUDYJEdVkyiwa+5D80tOGJkTKlTB4iotMor9HbDF5Mg20GcWH4yk/FRCZyDVYQ/qHGM6ERlEYGXysHxb8EVaISM5qatf1O1OrrXmsybtsnhXq5k1izG5MUmn5rePv+5cBMxS2fgPt1D2937TbWKYk8Y6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610079035; 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=86z8AYxAIJjDocnYRNlw15cBJhusZV0AjHOkYw4HibI=; b=G1odVkFeYEmLCneEHV/vK7LRgldHJVIcTmUJe3ZYF5YXgSBLbgJxsCkujRkTNkI/Xtg8i1ewm/SOm3oh2JvpwszDrsUd92PvcjoOCAIcYWKYbs15vua7uWD4FTvgySQIRANtWDnCMvLakuQGBJKnm5AB9Vueq808Emuf3+aB7ds= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1610079035028385.37696361864073; Thu, 7 Jan 2021 20:10:35 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-RGMUyiaPNgCF32SXPlKPYg-1; Thu, 07 Jan 2021 23:10:31 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DAFD5801AA7; Fri, 8 Jan 2021 04:10:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A2C219D7D; Fri, 8 Jan 2021 04:10:25 +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 E0F02180954D; Fri, 8 Jan 2021 04:10:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10849J6o008965 for ; Thu, 7 Jan 2021 23:09:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3F70071C82; Fri, 8 Jan 2021 04:09:19 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-37.phx2.redhat.com [10.3.112.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A53E5F9D0 for ; Fri, 8 Jan 2021 04:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610079033; 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=86z8AYxAIJjDocnYRNlw15cBJhusZV0AjHOkYw4HibI=; b=etfE63+Jh0vpZo6pJ3HwQ6loj2SL8ugyx6e8DTi/M+n0wTlM8Hrnwl/Ag1zKwGboNN+pbw AU65Z4zyfChF4DgOJomzNPct9p0u72PyCnuVcj15oKIwjDDC9CLb/V7NlLUa3kulRXSq+C I9J2BTgeZu/mj8luDXPX2YCDTJweXQ8= X-MC-Unique: RGMUyiaPNgCF32SXPlKPYg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] util: virSkipToDigit() Date: Thu, 7 Jan 2021 23:09:12 -0500 Message-Id: <20210108040913.172642-2-laine@redhat.com> In-Reply-To: <20210108040913.172642-1-laine@redhat.com> References: <20210108040913.172642-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.84 on 10.5.11.23 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) Content-Type: text/plain; charset="utf-8" This function skips over the beginning of a string until it reaches a decimal digit (0-9) or the NULL at the end of the string. The original pointer is modified in place (similar to virSkipSpaces()). Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virstring.c | 18 ++++++++++++++++++ src/util/virstring.h | 1 + 3 files changed, 20 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c67bd2504a..c325040b60 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3217,6 +3217,7 @@ virStorageFileBackendRegister; virSkipSpaces; virSkipSpacesAndBackslash; virSkipSpacesBackwards; +virSkipToDigit; virStrcpy; virStringBufferIsPrintable; virStringFilterChars; diff --git a/src/util/virstring.c b/src/util/virstring.c index 5578a5545b..521f2de3f6 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -752,6 +752,24 @@ virSkipSpacesAndBackslash(const char **str) *str =3D cur; } =20 + +/** + * virSkipToDigit: + * @str: pointer to the char pointer used + * + * Skip over any character that is not 0-9 + */ +void +virSkipToDigit(const char **str) +{ + const char *cur =3D *str; + + while (*cur && !g_ascii_isdigit(*cur)) + cur++; + *str =3D cur; +} + + /** * virTrimSpaces: * @str: string to modify to remove all trailing spaces diff --git a/src/util/virstring.h b/src/util/virstring.h index 210e43a953..55547b040a 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -110,6 +110,7 @@ int virDoubleToStr(char **strp, double number) =20 void virSkipSpaces(const char **str) ATTRIBUTE_NONNULL(1); void virSkipSpacesAndBackslash(const char **str) ATTRIBUTE_NONNULL(1); +void virSkipToDigit(const char **str) ATTRIBUTE_NONNULL(1); void virTrimSpaces(char *str, char **endp) ATTRIBUTE_NONNULL(1); void virSkipSpacesBackwards(const char *str, char **endp) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); --=20 2.29.2 From nobody Thu Mar 28 18:54:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1610079039; cv=none; d=zohomail.com; s=zohoarc; b=Mv1LBfmtNl6RpXvG2GGsIJ/rooU0JyiPrx1r+hOrESXAuvLnb6Wsn9wf0v7NQPX4dZcyWn86Gar5x0sdrAnZFZnl2Ua/UzxJT0VxFRui/ihNN9N4oYWTj7wIOvb9JyniWkP1FeV37zq5RppfwEJ1+RBzODs+Cm/I1P7hxE3+PP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610079039; 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=zTF97hJsKJ15qLsbIIwJQrU0NUJLTW29MO/06dz8ENU=; b=fKYEVyXe7vX8YPN+R9V2vyb8rLOAYU2RYR+o3CzoaJtZivXtGxrcCRVyjk/K1yIIhhEvzWux91TKujY6yC5PZCv4Np1QQ+zmWhn69XxD3jNBpU3S+HfgdQhTkgcJtfbXNn7BeBTccRrUjWE0tFRBowUnPHmvuvgtMKFS2tA0vT8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1610079039978277.132326881714; Thu, 7 Jan 2021 20:10:39 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-50-fixRaMY0OEyIaEkgIUtJ0w-1; Thu, 07 Jan 2021 23:10:36 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6FA4D192AB74; Fri, 8 Jan 2021 04:10:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E57B5D9DE; Fri, 8 Jan 2021 04:10:30 +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 17A631809CA0; Fri, 8 Jan 2021 04:10:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10849Jav008972 for ; Thu, 7 Jan 2021 23:09:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 952AF71CBF; Fri, 8 Jan 2021 04:09:19 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-37.phx2.redhat.com [10.3.112.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 604B55F9D0 for ; Fri, 8 Jan 2021 04:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610079038; 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=zTF97hJsKJ15qLsbIIwJQrU0NUJLTW29MO/06dz8ENU=; b=aVtZ29h/8yIWSr209LuYTC15JF4O56ay8oO1quLnbqWfH2kGyNMA/5TppG4x1WHw81hYB4 UsQStYhaTmo5B+oXP0n11iGIZAijUCUhVyoTJ1tIz58HQtRVBYOym/56PKnhVRMlrthEoM zbbZXTgT7foEHb3atWwlK7WnmegPxX0= X-MC-Unique: fixRaMY0OEyIaEkgIUtJ0w-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] util: Skip over any extra verbiage preceding version in dnsmasq version string Date: Thu, 7 Jan 2021 23:09:13 -0500 Message-Id: <20210108040913.172642-3-laine@redhat.com> In-Reply-To: <20210108040913.172642-1-laine@redhat.com> References: <20210108040913.172642-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.14 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) Content-Type: text/plain; charset="utf-8" dnsmasq usually prints out a version string like this: Dnsmasq version 2.82 [...] but a user reported that the build of dnsmasq included with pihole has a version string like this: Dnsmasq version pi-hole-2.81 [...] We parse the dnsmasq version number to figure out if the dnsmasq binary supports certain features. Since we expect the version number (and it must be only numbers!) to start on the first non-space after the string "Dnsmasq version", we fail to parse this format of the version string. Rather than spending a bunch of time trying to get pihole to change that, we can just make our parsing more permissive - after searching for "Dnsmasq version", we'll skip ahead to the first decimal digit, rather than just the first non-space. (NB: The features we're checking for purely by looking at version number have been in all releases of dnsmasq since at least 2012, so we could actually just remove the reading of the version number completely. However it's possible (although *highly* unlikely) that some new feature would be added to dnsmasq in the future and we would need to add that code back.) Resolves: https://gitlab.com/libvirt/libvirt/-/issues/29 Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/util/virdnsmasq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 5f477c976d..63ac088e06 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -638,7 +638,9 @@ dnsmasqCapsSetFromBuffer(dnsmasqCapsPtr caps, const cha= r *buf) p =3D STRSKIP(buf, DNSMASQ_VERSION_STR); if (!p) goto fail; - virSkipSpaces(&p); + + virSkipToDigit(&p); + if (virParseVersionString(p, &caps->version, true) < 0) goto fail; =20 --=20 2.29.2