From db4e4d72eff588423c7151853c1628f2fccdf787 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Thu, 6 Apr 2017 17:44:36 +0200 Subject: [PATCH] utils: fix KEY_* defines 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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/utils.h b/lib/utils.h index 271aa3715..24f652fa7 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -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) -- 2.47.3