]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Safeguard alias loop while looking in the cache for expired answers.
authorYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Tue, 3 Dec 2024 13:10:17 +0000 (14:10 +0100)
committerYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Tue, 3 Dec 2024 13:10:17 +0000 (14:10 +0100)
doc/Changelog
services/mesh.c

index fdcf53f3c9600f8014a1d19e1977768877d0eb5a..5e625dc9793a054a2ca47c64b430f5459bbbc439 100644 (file)
@@ -6,6 +6,7 @@
          (1 day) as suggested by RFC8767.
        - Merge #1198: Fix log-servfail with serve expired and no useful cache
          contents.
+       - Safeguard alias loop while looking in the cache for expired answers.
 
 22 November 2024: Yorgos
        - Fix #1175: serve-expired does not adhere to secure-by-default
index 18a53b4a5947d59c240e1c9a77cdcc4c10d408ec..a25094d12f1e876f40c08dc3c2e00f83faeeefa6 100644 (file)
@@ -2183,7 +2183,7 @@ mesh_serve_expired_callback(void* arg)
        struct timeval tv = {0, 0};
        int must_validate = (!(qstate->query_flags&BIT_CD)
                || qstate->env->cfg->ignore_cd) && qstate->env->need_to_validate;
-       int i = 0;
+       int i = 0, for_count;
        int is_expired;
        if(!qstate->serve_expired_data) return;
        verbose(VERB_ALGO, "Serve expired: Trying to reply with expired data");
@@ -2196,9 +2196,10 @@ mesh_serve_expired_callback(void* arg)
                        "Serve expired: Not allowed to look into cache for stale");
                return;
        }
-       /* The following while is used instead of the `goto lookup_cache`
-        * like in the worker. */
-       while(1) {
+       /* The following for is used instead of the `goto lookup_cache`
+        * like in the worker. This loop should get max 2 passes if we need to
+        * do any aliasing. */
+       for(for_count = 0; for_count < 2; for_count++) {
                fptr_ok(fptr_whitelist_serve_expired_lookup(
                        qstate->serve_expired_data->get_cached_answer));
                msg = (*qstate->serve_expired_data->get_cached_answer)(qstate,