]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nss-resolve: accept zero ifindex when parsing resolved reply
authorLennart Poettering <lennart@poettering.net>
Fri, 5 Feb 2021 17:44:22 +0000 (18:44 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 5 Feb 2021 17:44:22 +0000 (18:44 +0100)
Sometimes a reply isn't associated to any specific interface, it might
be a general truth (for example served from /etc/hosts or so). In this
case the server might pass ifindex == 0. Accept that.

https://github.com/systemd/systemd/pull/17823#issuecomment-742439422

src/nss-resolve/nss-resolve.c

index be9d28d993071d97fa16e397e0eb6438ed054d84..458eb487a5f0531856d3714642a22b9d3600cca1 100644 (file)
@@ -90,7 +90,7 @@ static int json_dispatch_ifindex(const char *name, JsonVariant *variant, JsonDis
                 return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an integer.", strna(name));
 
         t = json_variant_integer(variant);
-        if (t <= 0 || t > INT_MAX)
+        if (t > INT_MAX)
                 return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is out of bounds for an interface index.", strna(name));
 
         *ifi = (int) t;