Skip to content

Commit

Permalink
check length
Browse files Browse the repository at this point in the history
  • Loading branch information
miyako committed Nov 11, 2021
1 parent 5df33cf commit 826f2a1
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 76 deletions.
96 changes: 46 additions & 50 deletions SCARD-v3/4DPlugin-SCARD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,58 +950,52 @@ static void SCARD_Read_tag(PA_PluginParameters params) {
uint8_t bd[16];
std::string hex;

// for (int i = 0; i < 10; ++i) {

packet_write(devinfop, cmd, sizeof(cmd), usbbufp, timeout);//InCommRF
packet_write(devinfop, cmd, sizeof(cmd), usbbufp, timeout);//InCommRF

isPolling = true;
time_t startTime = time(0);
time_t anchorTime = startTime;
while (isPolling) {
time_t now = time(0);
time_t elapsedTime = abs(startTime - now);
elapsedTime = abs(anchorTime - now);

isPolling = true;
time_t startTime = time(0);
time_t anchorTime = startTime;
while (isPolling) {
time_t now = time(0);
time_t elapsedTime = abs(startTime - now);
elapsedTime = abs(anchorTime - now);

if(elapsedTime < timeout) {
len = packet_sens_req(devinfop, nfc_type, usbbufp, LIBUSB_API_TIMEOUT_FOR_POLLING);
if(len >= 0) {
if(usbbuf[9] == 0x05 && usbbuf[10] == 0x00) {
int rlen = ((usbbuf[6] << 8) + usbbuf[5]);
switch (rlen) {
case 52:

memcpy(bd, &usbbuf[28], 16);
print_hex(bd, 16, hex);
data.append(hex);

memcpy(bd, &usbbuf[28+16], 16);
print_hex(bd, 16, hex);
data.append(hex);

cmd[18] = cmd[18] + 2;
cmd[20] = cmd[20] + 2;

break;
default:
break;
}

// NSLog(@"rlen:%d, cmd[20]:%d",rlen, cmd[20]);

if(cmd[20] == 19){
isPolling = false;
}else{
packet_write(devinfop, cmd, sizeof(cmd), usbbufp, timeout);//InCommRF
}
if(elapsedTime < timeout) {
len = packet_sens_req(devinfop, nfc_type, usbbufp, LIBUSB_API_TIMEOUT_FOR_POLLING);
if(len >= 0) {
if(usbbuf[9] == 0x05 && usbbuf[10] == 0x00) {
int rlen = ((usbbuf[6] << 8) + usbbuf[5]);
switch (rlen) {
case 52:

memcpy(bd, &usbbuf[28], 16);
print_hex(bd, 16, hex);
data.append(hex);

memcpy(bd, &usbbuf[28+16], 16);
print_hex(bd, 16, hex);
data.append(hex);

cmd[18] = cmd[18] + 2;
cmd[20] = cmd[20] + 2;

break;
default:
break;
}

if(cmd[20] == 19){
isPolling = false;
}else{
packet_write(devinfop, cmd, sizeof(cmd), usbbufp, timeout);//InCommRF
}
}
}else{
/* timeout */
isPolling = false;
}
}else{
/* timeout */
isPolling = false;
}

// }
}

service["data"] = data;

Expand Down Expand Up @@ -1147,9 +1141,11 @@ static void SCARD_Read_tag(PA_PluginParameters params) {

if (error == nil)
{
std::string hex;
print_hex((const uint8_t *)[response bytes], 16, hex);
data.append(hex);
if([response length] == 16) {
std::string hex;
print_hex((const uint8_t *)[response bytes], 16, hex);
data.append(hex);
}
}

cnt++;
Expand Down
2 changes: 1 addition & 1 deletion SCARD-v3/English.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/* Localized versions of Info.plist keys */CFBundleName = "SCARD";CFBundleShortVersionString = "3.1.0";CFBundleGetInfoString = "SCARD version 3.1.0, Copyright 2021 miyako.";
/* Localized versions of Info.plist keys */CFBundleName = "SCARD";CFBundleShortVersionString = "3.1.1";CFBundleGetInfoString = "SCARD version 3.1.1, Copyright 2021 miyako.";
Expand Down
Binary file modified SCARD-v3/SCARD.dmg
Binary file not shown.
6 changes: 3 additions & 3 deletions SCARD-v3/SCARD.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
"$(PROJECT_DIR)/a",
);
LIBRARY_STYLE = Bundle;
MARKETING_VERSION = 3.1.0;
MARKETING_VERSION = 3.1.1;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
Expand Down Expand Up @@ -409,7 +409,7 @@
"$(PROJECT_DIR)/a",
);
LIBRARY_STYLE = Bundle;
MARKETING_VERSION = 3.1.0;
MARKETING_VERSION = 3.1.1;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
Expand Down Expand Up @@ -458,7 +458,7 @@
"$(PROJECT_DIR)/a",
);
LIBRARY_STYLE = Bundle;
MARKETING_VERSION = 3.1.0;
MARKETING_VERSION = 3.1.1;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,4 @@
uuid = "8B8D6F56-680C-485A-A863-49B18FC301DC"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "E5871DE9-2FFF-4A7F-A7C5-B4E02EA34B42"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "4DPlugin-SCARD.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "831"
endingLineNumber = "831"
landmarkName = "SCARD_Read_tag(params)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Binary file modified SCARD-v3/SCARD.zip
Binary file not shown.
Binary file modified SCARD-v3/test/Data/data.4DD
Binary file not shown.
Binary file modified SCARD-v3/test/Data/data.journal
Binary file not shown.
2 changes: 1 addition & 1 deletion SCARD-v3/test/Plugins/SCARD.bundle/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>3.1.0</string>
<string>3.1.1</string>
<key>CFBundleSignature</key>
<string>4D06</string>
<key>CFBundleSupportedPlatforms</key>
Expand Down
Binary file modified SCARD-v3/test/Plugins/SCARD.bundle/Contents/MacOS/SCARD
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<dict>
<key>hash</key>
<data>
iwQPMwfuNJoCTZI+MSrTHXM+EOY=
AHYuoCZNcHAgyvHbXMO6TdMTRKQ=
</data>
<key>optional</key>
<true/>
Expand All @@ -31,7 +31,7 @@
<dict>
<key>hash2</key>
<data>
PTqqGAkHJSAVkGUTc+6MvISx1qnLnH9brLQCWpbtemw=
EjRTVP2jxhWDmV1wVqFCEnectN5sLskrtjB8CqjK8/Y=
</data>
<key>optional</key>
<true/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?><preferences stamp="92">
<?xml version="1.0" encoding="UTF-8"?><preferences stamp="98">
<com.4d>
<database>
<data_storage data_path="Data/data.4DD"/>
Expand Down

0 comments on commit 826f2a1

Please sign in to comment.