From be7d8fafe292424ba0fdecf6687c5c72f85a25d1 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Wed, 31 Jan 2024 13:01:13 +0000 Subject: [PATCH 1/3] Fix the DNS_GETDB_STALEFIRST flag The DNS_GETDB_STALEFIRST flag is defined as 0x0C, which is the combination of the DNS_GETDB_PARTIAL (0x04) and the DNS_GETDB_IGNOREACL (0x08) flags (0x04 | 0x08 == 0x0C) , which is an obvious error. All the flags should be power of two, so they don't interfere with each other. Fix the DNS_GETDB_STALEFIRST flag by setting it to 0x10. --- lib/ns/query.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ns/query.c b/lib/ns/query.c index 34e47e2b1e..01775033f5 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -200,7 +200,7 @@ client_trace(ns_client_t *client, int level, const char *message) { #define DNS_GETDB_NOLOG 0x02U #define DNS_GETDB_PARTIAL 0x04U #define DNS_GETDB_IGNOREACL 0x08U -#define DNS_GETDB_STALEFIRST 0X0CU +#define DNS_GETDB_STALEFIRST 0X10U #define PENDINGOK(x) (((x) & DNS_DBFIND_PENDINGOK) != 0) From 0d7c7777da160ff0fc1fd2e4942826d8af50f1bf Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Wed, 31 Jan 2024 13:12:27 +0000 Subject: [PATCH 2/3] Improve the definition of the DNS_GETDB_* flags Use the (1 << N) form for defining the flags, in order to avoid errors like the one fixed in the previous commit. Also convert the definitions to an enum, as done in some of our recent refactoring work. --- lib/ns/query.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/ns/query.c b/lib/ns/query.c index 01775033f5..8017d04594 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -196,11 +196,13 @@ client_trace(ns_client_t *client, int level, const char *message) { #define CCTRACE(l, m) ((void)m) #endif /* WANT_QUERYTRACE */ -#define DNS_GETDB_NOEXACT 0x01U -#define DNS_GETDB_NOLOG 0x02U -#define DNS_GETDB_PARTIAL 0x04U -#define DNS_GETDB_IGNOREACL 0x08U -#define DNS_GETDB_STALEFIRST 0X10U +enum { + DNS_GETDB_NOEXACT = 1 << 0, + DNS_GETDB_NOLOG = 1 << 1, + DNS_GETDB_PARTIAL = 1 << 2, + DNS_GETDB_IGNOREACL = 1 << 3, + DNS_GETDB_STALEFIRST = 1 << 4, +}; #define PENDINGOK(x) (((x) & DNS_DBFIND_PENDINGOK) != 0) From f329c1ebc9f6c429eb09200beca70cef179c4475 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Wed, 31 Jan 2024 13:16:21 +0000 Subject: [PATCH 3/3] Add a CHANGES note for [GL !8683] --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 0abf9382b2..4568845a5b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +6333. [bug] Fix the DNS_GETDB_STALEFIRST flag, which was defined + incorrectly in lib/ns/query.c. [GL !8683] + 6332. [bug] Range-check the arguments to fetch-quota-param. [GL #362]