Fix mad_get_aid(): sector 0x10 is reserved and cannot be used.

This commit is contained in:
Romain Tartiere 2009-12-21 13:31:42 +00:00
parent c7b8574e23
commit 0ae63092bd

6
mad.c
View file

@ -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;