mirror of
https://github.com/RfidResearchGroup/ChameleonMini.git
synced 2026-05-12 11:20:37 -07:00
Testing a check for out of bound access when requesting invalind sectors from the tag. Fixed indentation.
This commit is contained in:
committed by
Thorsten Bosbach
parent
681e793c8d
commit
b0f40ebc9a
@@ -3,7 +3,8 @@
|
||||
*
|
||||
* Created on: 01-03-2017
|
||||
* Author: Phillip Nash
|
||||
* modified by rickventura for texas 15693 tag-it STANDARD
|
||||
* Modified by rickventura for texas 15693 tag-it STANDARD
|
||||
* Modified by ceres-c to finish things up
|
||||
*/
|
||||
|
||||
|
||||
@@ -15,6 +16,7 @@
|
||||
#include "ISO15693-A.h"
|
||||
|
||||
#define BYTES_PER_PAGE 4
|
||||
#define NUMBER_OF_SECTORS ( ISO15693_GENERIC_MEM_SIZE / BYTES_PER_PAGE )
|
||||
#define MEM_UID_ADDRESS 0x20
|
||||
|
||||
static enum {
|
||||
@@ -28,7 +30,6 @@ static enum {
|
||||
//0x07 = TEXAS INSTRUMENTS
|
||||
//0xC0 0xC1 = "Tagitstandard" 0xC4 or 0xC5 "TagitPro" 0x00 or 0x01 or 0x80 or 0x81 "Tagitplus"
|
||||
|
||||
|
||||
void TITagitstandardAppInit(void)
|
||||
{
|
||||
State = STATE_READY;
|
||||
@@ -42,13 +43,13 @@ void TITagitstandardAppReset(void)
|
||||
|
||||
void TITagitstandardAppTask(void)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void TITagitstandardAppTick(void)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// void sendIntToTermina(uint8_t val)
|
||||
@@ -60,9 +61,6 @@ void TITagitstandardAppTick(void)
|
||||
|
||||
uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (FrameBytes >= ISO15693_MIN_FRAME_SIZE) {
|
||||
if(ISO15693CheckCRC(FrameBuf, FrameBytes - ISO15693_CRC16_SIZE)) {
|
||||
// At this point, we have a valid ISO15693 frame
|
||||
@@ -70,20 +68,20 @@ uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
|
||||
uint16_t ResponseByteCount = ISO15693_APP_NO_RESPONSE;
|
||||
uint8_t Uid[8];
|
||||
|
||||
//MemoryReadBlock(actualTagIt, 0, 44); // read the whole tag from FRAM
|
||||
//MemoryReadBlock(actualTagIt, 0, 44); // read the whole tag from FRAM
|
||||
MemoryReadBlock(Uid, MEM_UID_ADDRESS, ActiveConfiguration.UidSize);
|
||||
|
||||
|
||||
//for (j==0 ; j < ActiveConfiguration.UidSize; j++) Uid[j] = actualTagIt[MEM_UID_ADDRESS + j] ;
|
||||
|
||||
switch(State) {
|
||||
case STATE_READY:
|
||||
if (Command == ISO15693_CMD_INVENTORY) {
|
||||
FrameBuf[0] = 0x00; /* Flags */
|
||||
FrameBuf[1] = 0x00; /* DSFID */
|
||||
FrameBuf[1] = 0x00; /* DSFID */
|
||||
ISO15693CopyUid(&FrameBuf[2], Uid);
|
||||
|
||||
|
||||
ResponseByteCount = 10;
|
||||
|
||||
|
||||
|
||||
} else if (Command == ISO15693_CMD_STAY_QUIET) {
|
||||
if (ISO15693Addressed(FrameBuf,Uid)) {
|
||||
@@ -92,57 +90,54 @@ uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
|
||||
}
|
||||
|
||||
} else if (Command == ISO15693_CMD_READ_SINGLE) {
|
||||
uint8_t *FramePtr ;
|
||||
uint8_t PageAddress ;
|
||||
|
||||
|
||||
if ((FrameBuf[0] & ISO15693_REQ_FLAG_ADDRESS) && ISO15693CompareUid(&FrameBuf[2], Uid) )
|
||||
PageAddress = FrameBuf[10]; /*when receiving anaddressed request pick block number from the 10th byte in the request*/
|
||||
else
|
||||
PageAddress = FrameBuf[2];
|
||||
|
||||
|
||||
if (FrameBuf[0] & ISO15693_REQ_FLAG_OPTION)
|
||||
{ /*request with option flag set */
|
||||
FrameBuf[0] = 0x00; /* Flags */
|
||||
FrameBuf[1] = ( PageAddress == 8 || PageAddress == 9) ? 0x02 : 0x00; /* block security status:when request has the option flag set*/
|
||||
FramePtr = FrameBuf + 2;
|
||||
ResponseByteCount = 6;
|
||||
uint8_t *FramePtr ;
|
||||
uint8_t PageAddress ;
|
||||
|
||||
} else { /*request with option flag not set*/
|
||||
FrameBuf[0] = 0x00; /* Flags */
|
||||
FramePtr = FrameBuf + 1 ;
|
||||
ResponseByteCount = 5;
|
||||
}
|
||||
|
||||
MemoryReadBlock(FramePtr, PageAddress * BYTES_PER_PAGE, BYTES_PER_PAGE);
|
||||
if ((FrameBuf[0] & ISO15693_REQ_FLAG_ADDRESS) && ISO15693CompareUid(&FrameBuf[2], Uid) )
|
||||
PageAddress = FrameBuf[10]; /* when receiving an addressed request pick block number from the 10th byte in the request*/
|
||||
else
|
||||
PageAddress = FrameBuf[2];
|
||||
|
||||
if (PageAddress > NUMBER_OF_SECTORS) { /* the reader is requesting a sector out of bound */
|
||||
FrameBuf[0] = ISO15693_RES_FLAG_ERROR;
|
||||
FrameBuf[1] = ISO15693_RES_ERR_BLK_NOT_AVL; // Is this enough?
|
||||
ResponseByteCount = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (FrameBuf[0] & ISO15693_REQ_FLAG_OPTION) { /* request with option flag set */
|
||||
FrameBuf[0] = 0x00; /* Flags */
|
||||
FrameBuf[1] = ( PageAddress == 8 || PageAddress == 9) ? 0x02 : 0x00; /* block security status:when request has the option flag set*/
|
||||
FramePtr = FrameBuf + 2;
|
||||
ResponseByteCount = 6;
|
||||
} else { /* request with option flag not set*/
|
||||
FrameBuf[0] = 0x00; /* Flags */
|
||||
FramePtr = FrameBuf + 1 ;
|
||||
ResponseByteCount = 5;
|
||||
}
|
||||
|
||||
else if (Command ==ISO15693_CMD_WRITE_SINGLE){
|
||||
uint8_t* Dataptr;
|
||||
uint8_t PageAddress ;
|
||||
|
||||
|
||||
if ((FrameBuf[0] & ISO15693_REQ_FLAG_ADDRESS) && ISO15693CompareUid(&FrameBuf[2], Uid) ){
|
||||
PageAddress = FrameBuf[10]; /*when receiving anaddressed request pick block number from 10th byte in the request*/
|
||||
Dataptr = &FrameBuf[11];
|
||||
}
|
||||
else {
|
||||
|
||||
PageAddress = FrameBuf[2];/*when receiving an unanaddressed request pick block number from 2nd byte in the request*/
|
||||
Dataptr = &FrameBuf[3];
|
||||
|
||||
}
|
||||
|
||||
MemoryWriteBlock( Dataptr , PageAddress * BYTES_PER_PAGE, BYTES_PER_PAGE);
|
||||
FrameBuf[0] = 0x00;
|
||||
ResponseByteCount = 1;
|
||||
|
||||
}
|
||||
MemoryReadBlock(FramePtr, PageAddress * BYTES_PER_PAGE, BYTES_PER_PAGE);
|
||||
}
|
||||
|
||||
else if (Command ==ISO15693_CMD_WRITE_SINGLE){
|
||||
uint8_t* Dataptr;
|
||||
uint8_t PageAddress ;
|
||||
|
||||
|
||||
if ((FrameBuf[0] & ISO15693_REQ_FLAG_ADDRESS) && ISO15693CompareUid(&FrameBuf[2], Uid) ){
|
||||
PageAddress = FrameBuf[10]; /*when receiving anaddressed request pick block number from 10th byte in the request*/
|
||||
Dataptr = &FrameBuf[11];
|
||||
} else {
|
||||
PageAddress = FrameBuf[2]; /*when receiving an unanaddressed request pick block number from 2nd byte in the request*/
|
||||
Dataptr = &FrameBuf[3];
|
||||
}
|
||||
|
||||
MemoryWriteBlock( Dataptr , PageAddress * BYTES_PER_PAGE, BYTES_PER_PAGE);
|
||||
FrameBuf[0] = 0x00;
|
||||
ResponseByteCount = 1;
|
||||
}
|
||||
break;
|
||||
case STATE_SELECTED:
|
||||
|
||||
break;
|
||||
|
||||
case STATE_QUIET:
|
||||
@@ -166,14 +161,14 @@ uint16_t TITagitstandardAppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
|
||||
}
|
||||
|
||||
return ResponseByteCount;
|
||||
|
||||
|
||||
} else { // Invalid CRC
|
||||
return ISO15693_APP_NO_RESPONSE;
|
||||
}
|
||||
} else { // Min frame size not met
|
||||
return ISO15693_APP_NO_RESPONSE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void TITagitstandardGetUid(ConfigurationUidType Uid)
|
||||
@@ -184,9 +179,4 @@ void TITagitstandardGetUid(ConfigurationUidType Uid)
|
||||
void TITagitstandardSetUid(ConfigurationUidType Uid)
|
||||
{
|
||||
MemoryWriteBlock(Uid, MEM_UID_ADDRESS, ActiveConfiguration.UidSize);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user