[libvirt PATCH 2/2] util: Skip over any extra verbiage preceding version in dnsmasq version string

Laine Stump laine at redhat.com
Fri Jan 8 04:09:13 UTC 2021


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 <laine at redhat.com>
---
 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 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.29.2




More information about the libvir-list mailing list