From 0ae63092bd3e9784019f78026225a58a2a31c89f Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Mon, 21 Dec 2009 13:31:42 +0000 Subject: [PATCH] Fix mad_get_aid(): sector 0x10 is reserved and cannot be used. --- mad.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mad.c b/mad.c index 6384d9c..d51584e 100644 --- a/mad.c +++ b/mad.c @@ -286,7 +286,7 @@ mad_set_card_publisher_sector(Mad mad, MifareSectorNumber cps) int mad_get_aid(Mad mad, MifareSectorNumber sector, MadAid *aid) { - if (sector > 0x27) { + if ((sector < 1) || (sector == 0x10) || (sector > 0x27)) { errno = EINVAL; return -1; } @@ -297,8 +297,8 @@ mad_get_aid(Mad mad, MifareSectorNumber sector, MadAid *aid) return -1; } - aid->function_cluster_code = mad->sector_0x10.aids[sector - 0x0f - 1].function_cluster_code; - aid->application_code = mad->sector_0x10.aids[sector - 0x0f - 1].application_code; + aid->function_cluster_code = mad->sector_0x10.aids[sector - 0x0f - 2].function_cluster_code; + aid->application_code = mad->sector_0x10.aids[sector - 0x0f - 2].application_code; } else { aid->function_cluster_code = mad->sector_0x00.aids[sector - 1].function_cluster_code; aid->application_code = mad->sector_0x00.aids[sector - 1].application_code;