]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: initialize 'current' when SD_RESOLVED_NO_STALE is set 28568/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 31 Jul 2023 13:11:51 +0000 (22:11 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 31 Jul 2023 13:11:58 +0000 (22:11 +0900)
Otherwise, the check below is always fail.
```
if (FLAGS_SET(query_flags, SD_RESOLVED_NO_STALE) && j->until_valid < current)
```

Follow-up for 5ed91481abea382dc486507556e5cdf0f36b796f.

src/resolve/resolved-dns-cache.c

index 9d2a2fa1acbf946c386dcc52b0d39c2269ee4ac2..3805150d9811b8504f780d3d8e128b08e156e5eb 100644 (file)
@@ -1030,9 +1030,10 @@ int dns_cache_lookup(
                 goto miss;
         }
 
-        if (FLAGS_SET(query_flags, SD_RESOLVED_CLAMP_TTL)) {
+        if ((query_flags & (SD_RESOLVED_CLAMP_TTL | SD_RESOLVED_NO_STALE)) != 0) {
                 /* 'current' is always passed to answer_add_clamp_ttl(), but is only used conditionally.
-                 * We'll do the same assert there to make sure that it was initialized properly. */
+                 * We'll do the same assert there to make sure that it was initialized properly.
+                 * 'current' is also used below when SD_RESOLVED_NO_STALE is set. */
                 current = now(CLOCK_BOOTTIME);
                 assert(current > 0);
         }