]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
utils: fix KEY_* defines
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 6 Apr 2017 15:44:36 +0000 (17:44 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 6 Apr 2017 15:50:19 +0000 (17:50 +0200)
The argument to KEY_FLAG_RANK was (signed) char*, so for secure rank
the shift was setting the highest two bits (which are unused).
Let me end that rubbish.

lib/utils.h

index 271aa371504739166ce48b09ff58ab7b60e93835..24f652fa75083ef21caa1aafab797cfdcbd5aea6 100644 (file)
@@ -202,9 +202,11 @@ KR_EXPORT KR_PURE
 int kr_bitcmp(const char *a, const char *b, int bits);
 
 /** @internal RR map flags. */
-#define KEY_FLAG_RRSIG 0x02
-#define KEY_FLAG_RANK(key) (key[0] >> 2)
-#define KEY_COVERING_RRSIG(key) (key[0] & KEY_FLAG_RRSIG)
+static const uint8_t KEY_FLAG_RRSIG = 0x02;
+static inline uint8_t KEY_FLAG_RANK(const char *key)
+       { return ((uint8_t)(key[0])) >> 2; }
+static inline bool KEY_COVERING_RRSIG(const char *key)
+       { return ((uint8_t)(key[0])) & KEY_FLAG_RRSIG; }
 
 /* Stash key = {[1] flags, [1-255] owner, [5] type, [1] \x00 } */
 #define KR_RRKEY_LEN (9 + KNOT_DNAME_MAXLEN)