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

Add the final NUL to the CN used for token label #985

Closed
wants to merge 1 commit into from
Closed

Add the final NUL to the CN used for token label #985

wants to merge 1 commit into from

Conversation

martinpaljak
Copy link
Member

Arbitrary strings were shown in PKCS#11 apps (even though the field is cut to 32 characters)

Change-Id: I615334999c8309322b9397baf0db3447b0903881
@@ -117,7 +117,10 @@ sc_pkcs15emu_esteid_init (sc_pkcs15_card_t * p15card)
sc_pkcs15_get_name_from_dn(card->ctx, cert->subject,
cert->subject_len, &cn_oid, &cn_name, &cn_len);
if (cn_len > 0) {
set_string(&p15card->tokeninfo->label, (const char*)cn_name);
char *token_name = malloc(cn_len+1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add error checking

set_string(&p15card->tokeninfo->label, (const char*)cn_name);
char *token_name = malloc(cn_len+1);
memcpy(token_name, cn_name, cn_len);
token_name[cn_len] = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use '\0'

char *token_name = malloc(cn_len+1);
memcpy(token_name, cn_name, cn_len);
token_name[cn_len] = 0;
set_string(&p15card->tokeninfo->label, (const char*)token_name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token_name needs to be freed

hamano pushed a commit to jpki/OpenSC that referenced this pull request Apr 10, 2017
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 this pull request may close these issues.

None yet

2 participants