From bd463a77381e3233d3529fa445c0f57b7851006c Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Thu, 7 Jan 2021 20:03:05 -0500 Subject: [PATCH 081/108] util: Skip over any extra verbiage preceding version in dnsmasq version string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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án Tomko (cherry picked from commit a4be2e35db39df87fe70a638cf64c32be74f1a55) --- 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 adc6f96bb6..5a329ae278 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -648,7 +648,9 @@ dnsmasqCapsSetFromBuffer(dnsmasqCapsPtr caps, const char *buf) p = STRSKIP(buf, DNSMASQ_VERSION_STR); if (!p) goto fail; - virSkipSpaces(&p); + + virSkipToDigit(&p); + if (virParseVersionString(p, &caps->version, true) < 0) goto fail; -- 2.33.0