Reduce some var scopes

This commit is contained in:
Philippe Teuwen 2019-06-07 18:41:39 +02:00
commit 732bc766f9
52 changed files with 318 additions and 409 deletions

View file

@ -1051,9 +1051,6 @@ uint32_t GetHF14AMfU_Type(void) {
TagTypeUL_t tagtype = UNKNOWN;
iso14a_card_select_t card;
uint8_t version[10] = {0x00};
int status = 0;
int len;
if (!ul_select(&card)) return UL_ERROR;
@ -1066,7 +1063,8 @@ uint32_t GetHF14AMfU_Type(void) {
if (card.uid[0] != 0x05) {
len = ulev1_getVersion(version, sizeof(version));
uint8_t version[10] = {0x00};
int len = ulev1_getVersion(version, sizeof(version));
DropField();
switch (len) {
@ -1112,7 +1110,7 @@ uint32_t GetHF14AMfU_Type(void) {
// do UL_C check first...
uint8_t nonce[11] = {0x00};
status = ulc_requestAuthentication(nonce, sizeof(nonce));
int status = ulc_requestAuthentication(nonce, sizeof(nonce));
DropField();
if (status > 1) {
tagtype = UL_C;
@ -1944,10 +1942,8 @@ static int CmdHF14AMfUDump(const char *Cmd) {
iso14a_card_select_t card;
mfu_dump_t dump_file_data;
uint8_t get_pack[] = {0, 0};
uint8_t get_version[] = {0, 0, 0, 0, 0, 0, 0, 0};
uint8_t get_counter_tearing[][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
uint8_t dummy_pack[] = {0, 0};
uint8_t get_signature[32];
memset(get_signature, 0, sizeof(get_signature));
@ -1955,6 +1951,7 @@ static int CmdHF14AMfUDump(const char *Cmd) {
// VERSION, SIGNATURE, COUNTERS, TEARING, PACK,
if (!(tagtype & UL_C || tagtype & UL)) {
//attempt to read pack
uint8_t get_pack[] = {0, 0};
if (!ul_auth_select(&card, tagtype, true, authKeyPtr, get_pack, sizeof(get_pack))) {
//reset pack
get_pack[0] = 0;
@ -1969,9 +1966,10 @@ static int CmdHF14AMfUDump(const char *Cmd) {
memcpy(data + (pages * 4) - 4, get_pack, sizeof(get_pack));
}
if (hasAuthKey)
if (hasAuthKey) {
uint8_t dummy_pack[] = {0, 0};
ul_auth_select(&card, tagtype, hasAuthKey, authKeyPtr, dummy_pack, sizeof(dummy_pack));
else
} else
ul_select(&card);
ulev1_getVersion(get_version, sizeof(get_version));
@ -1981,9 +1979,10 @@ static int CmdHF14AMfUDump(const char *Cmd) {
}
DropField();
if (hasAuthKey)
if (hasAuthKey) {
uint8_t dummy_pack[] = {0, 0};
ul_auth_select(&card, tagtype, hasAuthKey, authKeyPtr, dummy_pack, sizeof(dummy_pack));
else
} else
ul_select(&card);
ulev1_readSignature(get_signature, sizeof(get_signature));