Skip to content

Commit 64488de

Browse files
olszomalmtrojnar
authored andcommitted
Fix null pointer dereference when accessing token label
1 parent 32c54b5 commit 64488de

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/util_uri.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ static void *UTIL_CTX_try_load_object(UTIL_CTX *ctx,
863863
UTIL_CTX_log(ctx, LOG_NOTICE, "- [%lu] %-25.25s %-36s (%s)\n",
864864
PKCS11_get_slotid_from_slot(slot),
865865
slot->description ? slot->description : "(no description)",
866-
flags, slot->token->label[0] ? slot->token->label : "no label");
866+
flags, slot->token && slot->token->label[0] ? slot->token->label : "no label");
867867

868868
/* Ignore slots without tokens. Thales HSM (and potentially
869869
* other modules) allow objects on uninitialized tokens. */
@@ -914,8 +914,8 @@ static void *UTIL_CTX_try_load_object(UTIL_CTX *ctx,
914914
}
915915
UTIL_CTX_log(ctx, LOG_NOTICE, "Found slot: %s\n",
916916
slot->description ? slot->description : "(no description)");
917-
UTIL_CTX_log(ctx, LOG_NOTICE, "Found token: %s\n", slot->token->label[0]?
918-
slot->token->label : "no label");
917+
UTIL_CTX_log(ctx, LOG_NOTICE, "Found token: %s\n",
918+
slot->token->label[0] ? slot->token->label : "no label");
919919

920920
/* Only try to login if login is required */
921921
if (slot->token->loginRequired || ctx->force_login) {
@@ -963,8 +963,8 @@ static void *UTIL_CTX_try_load_object(UTIL_CTX *ctx,
963963
slot = init_slots[0];
964964
UTIL_CTX_log(ctx, LOG_NOTICE, "Found slot: %s\n",
965965
slot->description ? slot->description : "(no description)");
966-
UTIL_CTX_log(ctx, LOG_NOTICE, "Found token: %s\n", slot->token->label[0]?
967-
slot->token->label : "no label");
966+
UTIL_CTX_log(ctx, LOG_NOTICE, "Found token: %s\n",
967+
slot->token->label[0] ? slot->token->label : "no label");
968968

969969
/* Only try to login if login is required */
970970
if (slot->token->loginRequired || ctx->force_login) {
@@ -997,8 +997,8 @@ static void *UTIL_CTX_try_load_object(UTIL_CTX *ctx,
997997
slot = uninit_slots[m];
998998
UTIL_CTX_log(ctx, LOG_NOTICE, "Found slot: %s\n",
999999
slot->description ? slot->description : "(no description)");
1000-
UTIL_CTX_log(ctx, LOG_NOTICE, "Found token: %s\n", slot->token->label[0]?
1001-
slot->token->label : "no label");
1000+
UTIL_CTX_log(ctx, LOG_NOTICE, "Found token: %s\n",
1001+
slot->token->label[0] ? slot->token->label : "no label");
10021002
object = match_func(ctx, slot->token, obj_id, obj_id_len, obj_label);
10031003
if (object) {
10041004
free(uninit_slots);
@@ -1022,8 +1022,8 @@ static void *UTIL_CTX_try_load_object(UTIL_CTX *ctx,
10221022
}
10231023
UTIL_CTX_log(ctx, LOG_NOTICE, "Found slot: %s\n",
10241024
slot->description ? slot->description : "(no description)");
1025-
UTIL_CTX_log(ctx, LOG_NOTICE, "Found token: %s\n", slot->token->label[0]?
1026-
slot->token->label : "no label");
1025+
UTIL_CTX_log(ctx, LOG_NOTICE, "Found token: %s\n",
1026+
slot->token && slot->token->label[0] ? slot->token->label : "no label");
10271027
object = match_func(ctx, slot->token, obj_id, obj_id_len, obj_label);
10281028
if (object)
10291029
break; /* success */

0 commit comments

Comments
 (0)