- opensc-tool -f: don't crash on large or record structured files
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@972 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
00d2d7ce4c
commit
0ea0ce2ac9
|
@ -201,25 +201,33 @@ int print_file(struct sc_card *card, const struct sc_file *file, const struct sc
|
||||||
hex_dump(stdout, file->prop_attr, file->prop_attr_len, ":");
|
hex_dump(stdout, file->prop_attr, file->prop_attr_len, ":");
|
||||||
}
|
}
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
#if 1
|
|
||||||
if (file->type != SC_FILE_TYPE_DF) {
|
if (file->type == SC_FILE_TYPE_DF)
|
||||||
u8 *buf = malloc(file->size);
|
return 0;
|
||||||
if (!buf) {
|
|
||||||
|
if (file->ef_structure == SC_FILE_EF_TRANSPARENT) {
|
||||||
|
unsigned char *buf;
|
||||||
|
|
||||||
|
if (!(buf = malloc(file->size))) {
|
||||||
fprintf(stderr, "out of memory");
|
fprintf(stderr, "out of memory");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (file->ef_structure == SC_FILE_EF_TRANSPARENT) {
|
|
||||||
r = sc_read_binary(card, 0, buf, file->size, 0);
|
r = sc_read_binary(card, 0, buf, file->size, 0);
|
||||||
if (r > 0)
|
if (r > 0)
|
||||||
hex_dump_asc(stdout, buf, r, 0);
|
hex_dump_asc(stdout, buf, r, 0);
|
||||||
} else {
|
free(buf);
|
||||||
r = sc_read_record(card, 0, buf, file->size, 0);
|
} else {
|
||||||
|
unsigned char buf[256];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < file->record_count; i++) {
|
||||||
|
printf("Record %d\n", i);
|
||||||
|
r = sc_read_record(card, i, buf, 256, 0);
|
||||||
if (r > 0)
|
if (r > 0)
|
||||||
hex_dump_asc(stdout, buf, r, 0);
|
hex_dump_asc(stdout, buf, r, 0);
|
||||||
}
|
}
|
||||||
free(buf);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue