Avoid accessing src[len] by swapping the check order and bound check
the iterator variable before the access.
Found by cppcheck.
Fixes: cc4ea5e00028 "Introduce new internal hashtable implementation"
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Wed Jun 24 13:09:25 2026
(Merged from https://github.com/openssl/openssl/pull/31663)
if (key != NULL && key->keysize + len > key->bufsize)
len = (size_t)(key->bufsize - key->keysize);
- for (i = 0; src[i] != '\0' && i < len; i++)
+ for (i = 0; i < len && src[i] != '\0'; i++)
tgt[i] = case_adjust & src[i];
}