Commit 45a19a4b authored by Nikos Mavrogiannopoulos's avatar Nikos Mavrogiannopoulos Committed by Niels Möller

des: assign value after sanity check to avoid undefined behavior

This corrects issues of the following type caught with -fsanitize=undefined
des.c:176:42: runtime error: index 42 out of bounds for type 'int8_t [26][4]'
parent 628a2c19
......@@ -173,10 +173,13 @@ des_weak_p(const uint8_t *key)
int8_t k1 = key[1] >> 1;
unsigned hash = asso_values[k1 + 1] + asso_values[k0];
const int8_t *candidate = weak_key_hash[hash];
const int8_t *candidate;
if (hash > 25)
return 0;
candidate = weak_key_hash[hash];
if (k0 != candidate[0]
|| k1 != candidate[1])
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment