From: Vladimír Čunát Date: Thu, 6 Apr 2017 15:44:36 +0000 (+0200) Subject: utils: fix KEY_* defines X-Git-Tag: v1.3.0~23^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db4e4d72eff588423c7151853c1628f2fccdf787;p=thirdparty%2Fknot-resolver.git 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. --- 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)