[pkg-opensc-commit] [opensc] 140/295: opensc-explorer: show tag 0x82 for unknown files

Eric Dorland eric at moszumanska.debian.org
Sat Jun 24 21:11:24 UTC 2017


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository opensc.

commit 539c89e581a7c54bf5e17f3bd82e7a608887aab2
Author: Peter Popovec <popovec.peter at gmail.com>
Date:   Thu Dec 15 16:22:11 2016 +0100

    opensc-explorer: show tag 0x82 for unknown files
    
    For reserved/unknown file type print value of 0x82 tag, instead of "???" string.
    
    closes #918
---
 src/libopensc/iso7816.c     |  2 ++
 src/tools/opensc-explorer.c | 23 ++++++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/libopensc/iso7816.c b/src/libopensc/iso7816.c
index bbab3b0..1d9a867 100644
--- a/src/libopensc/iso7816.c
+++ b/src/libopensc/iso7816.c
@@ -391,6 +391,8 @@ iso7816_process_fci(struct sc_card *card, struct sc_file *file,
 			}
 			sc_log(ctx, "  type: %s", type);
 			sc_log(ctx, "  EF structure: %d", byte & 0x07);
+			sc_log(ctx, "  tag 0x82: 0x%02x", byte);
+			sc_file_set_type_attr(file, &byte, 1);
 		}
 	}
 
diff --git a/src/tools/opensc-explorer.c b/src/tools/opensc-explorer.c
index 7cb3554..3bc9f8c 100644
--- a/src/tools/opensc-explorer.c
+++ b/src/tools/opensc-explorer.c
@@ -383,7 +383,10 @@ arg_to_path(const char *arg, sc_path_t *path, int is_id)
 static void print_file(const sc_file_t *file)
 {
 	const char *format = " %02X%02X ";
-	const char *st = "???";
+	const char *st = NULL;
+
+	if(!file->type_attr_len)
+		st = "???";
 
 	switch (file->type) {
 	case SC_FILE_TYPE_WORKING_EF:
@@ -398,7 +401,10 @@ static void print_file(const sc_file_t *file)
 		break;
 	}
 	printf(format, file->id >> 8, file->id & 0xFF);
-	printf("\t%4s", st);
+	if (st == NULL)
+		printf("\t0x%02X", *file->type_attr);
+	else
+		printf("\t%4s", st);
 	printf(" %5lu", (unsigned long)file->size);
 	if (file->namelen) {
 		printf("\tName: ");
@@ -825,7 +831,7 @@ static int do_info(int argc, char **argv)
 	sc_file_t *file;
 	sc_path_t path;
 	size_t i;
-	const char *st;
+	const char *st = NULL;
 	int r, not_current = 1;
 	const id2str_t *ac_ops = NULL;
 
@@ -845,6 +851,9 @@ static int do_info(int argc, char **argv)
 	} else
 		return usage(do_info);
 
+	if(!file->type_attr_len)
+		st = "Unknown File";
+
 	switch (file->type) {
 	case SC_FILE_TYPE_WORKING_EF:
 	case SC_FILE_TYPE_INTERNAL_EF:
@@ -853,11 +862,11 @@ static int do_info(int argc, char **argv)
 	case SC_FILE_TYPE_DF:
 		st = "Dedicated File";
 		break;
-	default:
-		st = "Unknown File";
-		break;
 	}
-	printf("\n%s  ID %04X", st, file->id);
+	if (st == NULL)
+		printf("\nFile type [%02x] ID %04X", *file->type_attr, file->id);
+	else
+		printf("\n%s  ID %04X", st, file->id);
 	if (file->sid)
 		printf(", SFI %02X", file->sid);
 	printf("\n\n%-15s%s\n", "File path:", path_to_filename(&path, '/'));

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/opensc.git



More information about the pkg-opensc-commit mailing list