Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minidriver crash if p15card->app is not set #3084

Closed
jozsefd opened this issue Mar 22, 2024 · 4 comments · Fixed by #3095
Closed

Minidriver crash if p15card->app is not set #3084

jozsefd opened this issue Mar 22, 2024 · 4 comments · Fixed by #3095

Comments

@jozsefd
Copy link
Contributor

jozsefd commented Mar 22, 2024

Problem Description

If the card is using a PKCS15 Emulator where the optional pointer to the sc_app_info in the sc_pkcs15_card structure is not set then the minidriver crashes. The function get_pin_by_name will crash, the log will look like:

P:10156; T:9336 2024-03-20 15:48:59.567 [cardmod] MD_Function:md_get_pin_by_role:541 called
P:10156; T:9336 2024-03-20 15:48:59.567 [cardmod] MD_Function:get_pin_by_name:499 called

Proposed Resolution

Add a check for the pointer. All other references to this pointer check it already.

	if ( p15card->app != NULL ) {
		sc_bin_to_hex(p15card->app->path.value, p15card->app->path.len, str_path, sizeof(str_path), 0);
		blocks = scconf_find_blocks(p15card->card->ctx->conf, conf_block, "application", str_path);
	}

Steps to reproduce

Insert a card which uses an emulator, not setting the p15card->app (e.g. nqApplet) and try to load the minidriver, like "certutil /scinfo".

Logs

P:10156; T:9336 2024-03-20 15:48:59.567 [cardmod] MD_Function:md_get_pin_by_role:541 called
P:10156; T:9336 2024-03-20 15:48:59.567 [cardmod] MD_Function:get_pin_by_name:499 called

@Jakuje
Copy link
Member

Jakuje commented Mar 22, 2024

Can you propose the change as a PR?

@jozsefd
Copy link
Contributor Author

jozsefd commented Mar 22, 2024

For sure, I have already created a branch with the fixes of #3084 #3085 and #3086. I will double check it as #3077 gets pulled.

@Jakuje
Copy link
Member

Jakuje commented Mar 27, 2024

I think this part is not fixed in #3077 as it is not completely related. Can you open a separate PR for this fix?

@jozsefd
Copy link
Contributor Author

jozsefd commented Apr 2, 2024

Opened PR #3095 with the suggested fix.

@jozsefd jozsefd closed this as completed Apr 2, 2024
xhanulik pushed a commit to xhanulik/OpenSC that referenced this issue Apr 4, 2024
xhanulik pushed a commit to xhanulik/OpenSC that referenced this issue Apr 4, 2024
xhanulik pushed a commit to xhanulik/OpenSC that referenced this issue Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants