Check for NUL in label to test its presence

This commit is contained in:
Frank Morgner 2015-10-05 08:30:47 +02:00
parent 5b0332528f
commit 137afb10b7
2 changed files with 4 additions and 4 deletions

View File

@ -2852,7 +2852,7 @@ static int verify_pin(struct sc_pkcs15_card *p15card, char *auth_id_str)
if (opt_no_prompt)
return SC_ERROR_OBJECT_NOT_FOUND;
if (0 < strnlen(pin_obj->label, sizeof pin_obj->label))
if (pin_obj->label[0])
snprintf(pin_label, sizeof(pin_label), "User PIN [%s]", pin_obj->label);
else
snprintf(pin_label, sizeof(pin_label), "User PIN");

View File

@ -477,7 +477,7 @@ static int list_data_objects(void)
int idx;
struct sc_pkcs15_data_info *cinfo = (struct sc_pkcs15_data_info *) objs[i]->data;
if (0 < strnlen(objs[i]->label, sizeof objs[i]->label))
if (objs[i]->label[0] != '\0')
printf("Data object '%.*s'\n",(int) sizeof objs[i]->label, objs[i]->label);
else
printf("Data object <%i>\n", i);
@ -822,7 +822,7 @@ static void print_ssh_key(FILE *outf, const char * alg, struct sc_pkcs15_object
fprintf(outf,"---- BEGIN SSH2 PUBLIC KEY ----\n");
if (strnlen(obj->label, sizeof obj->label))
if (obj->label[0] != '\0')
fprintf(outf,"Comment: \"%.*s\"\n", (int) sizeof obj->label, obj->label);
fprintf(outf,"%s", uu);
@ -834,7 +834,7 @@ static void print_ssh_key(FILE *outf, const char * alg, struct sc_pkcs15_object
if (r < 0)
return;
if (strnlen(obj->label, sizeof obj->label))
if (obj->label[0] != '\0')
fprintf(outf,"ssh-%s %s %.*s\n", alg, uu, (int) sizeof obj->label, obj->label);
else
fprintf(outf,"ssh-%s %s\n", alg, uu);