From f677bdc12fdb186c4aea86a7aed1182986908f3c Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Wed, 4 Mar 2020 17:57:16 +0100 Subject: [PATCH] Fix few bugs in previous commit. - crypt_token_register must not be called from withing crypt_token_load (see later commits) - minor bug in dlvsym/dlerror handling - check for overflow in LUKS2_token_handler_type --- lib/luks2/luks2_token.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/luks2/luks2_token.c b/lib/luks2/luks2_token.c index d3148719..d31cb473 100644 --- a/lib/luks2/luks2_token.c +++ b/lib/luks2/luks2_token.c @@ -67,12 +67,7 @@ static const crypt_token_handler token = dlvsym(handle, CRYPT_TOKEN_ABI_HANDLER, CRYPT_TOKEN_ABI_VERSION1); error = dlerror(); if (error) { - log_dbg(NULL, "%s", dlerror()); - dlclose(handle); - return NULL; - } - - if (crypt_token_register(token) < 0) { + log_dbg(NULL, "%s", error); dlclose(handle); return NULL; } @@ -144,10 +139,15 @@ static const crypt_token_handler if (!strcmp(token_handlers[i].h->name, type)) return token_handlers[i].h; + if (i >= LUKS2_TOKENS_MAX) + return NULL; + if (is_builtin_candidate(type)) return NULL; - return crypt_token_load_external(type); + token_handlers[i].h = crypt_token_load_external(type); + + return token_handlers[i].h; } static const crypt_token_handler