This commit is contained in:
Doridian committed 2022-06-11 15:32:08 -07:00
1 parent 6b951960f1
commit 789f807e83
4 files changed
+63 -61

No files matched your search

+26 -24
View File
@@ -78,16 +78,18 @@ void Set_t55xx_Config(t55xx_conf_block_t conf) {
static int CmdHelp(const char *Cmd);
static void arg_add_t55xx_downloadlink(void *at[], uint8_t *idx, uint8_t show, uint8_t dl_mode_def) {
const size_t r_count = 56;
const size_t r_len = r_count * sizeof(uint8_t);
char *r0 = (char *)calloc(56, sizeof(uint8_t));
char *r1 = (char *)calloc(56, sizeof(uint8_t));
char *r2 = (char *)calloc(56, sizeof(uint8_t));
char *r3 = (char *)calloc(56, sizeof(uint8_t));
char *r0 = (char *)calloc(r_count, sizeof(uint8_t));
char *r1 = (char *)calloc(r_count, sizeof(uint8_t));
char *r2 = (char *)calloc(r_count, sizeof(uint8_t));
char *r3 = (char *)calloc(r_count, sizeof(uint8_t));
sprintf(r0, "downlink - fixed bit length %s", (dl_mode_def == 0) ? "(detected def)" : "");
sprintf(r1, "downlink - long leading reference %s", (dl_mode_def == 1) ? "(detected def)" : "");
sprintf(r2, "downlink - leading zero %s", (dl_mode_def == 2) ? "(detected def)" : "");
sprintf(r3, "downlink - 1 of 4 coding reference %s", (dl_mode_def == 3) ? "(detected def)" : "");
snprintf(r0, r_len, "downlink - fixed bit length %s", (dl_mode_def == 0) ? "(detected def)" : "");
snprintf(r1, r_len, "downlink - long leading reference %s", (dl_mode_def == 1) ? "(detected def)" : "");
snprintf(r2, r_len, "downlink - leading zero %s", (dl_mode_def == 2) ? "(detected def)" : "");
snprintf(r3, r_len, "downlink - 1 of 4 coding reference %s", (dl_mode_def == 3) ? "(detected def)" : "");
uint8_t n = *idx;
at[n++] = arg_lit0(NULL, "r0", r0);
@@ -96,8 +98,8 @@ static void arg_add_t55xx_downloadlink(void *at[], uint8_t *idx, uint8_t show, u
at[n++] = arg_lit0(NULL, "r3", r3);
if (show == T55XX_DLMODE_ALL) {
char *r4 = (char *)calloc(56, sizeof(uint8_t));
sprintf(r4, "try all downlink modes %s", (dl_mode_def == 4) ? "(def)" : "");
char *r4 = (char *)calloc(r_count, sizeof(uint8_t));
snprintf(r4, r_len, "try all downlink modes %s", (dl_mode_def == 4) ? "(def)" : "");
at[n++] = arg_lit0(NULL, "all", r4);
}
at[n++] = arg_param_end;
@@ -961,7 +963,7 @@ static int CmdT55xxDetect(const char *Cmd) {
if (use_gb == false) {
char wakecmd[20] = { 0x00 };
sprintf(wakecmd, "-p %08" PRIx64, password);
snprintf(wakecmd, sizeof(wakecmd), "-p %08" PRIx64, password);
bool usewake = false;
bool try_with_pwd = false;
@@ -4010,7 +4012,7 @@ static int CmdT55xxSniff(const char *Cmd) {
size_t idx = 0;
uint32_t usedPassword, blockData;
int pulseSamples = 0, pulseIdx = 0;
char modeText[100];
const char *modeText;
char pwdText[100];
char dataText[100];
int pulseBuffer[80] = { 0 }; // max should be 73 +/- - Holds Pulse widths
@@ -4036,9 +4038,9 @@ static int CmdT55xxSniff(const char *Cmd) {
int maxWidth = 0;
data[0] = 0;
bool have_data = false;
sprintf(modeText, "Default");
sprintf(pwdText, " ");
sprintf(dataText, " ");
modeText = "Default";
strncpy(pwdText, " ", sizeof(pwdText));
strncpy(dataText, " ", sizeof(dataText));
if (pulseSamples == 0) {
idx++;
@@ -4133,7 +4135,7 @@ static int CmdT55xxSniff(const char *Cmd) {
}
blockData = 0;
have_data = true;
sprintf(modeText, "Default Read");
modeText = "Default Read";
}
// Password Write
@@ -4161,9 +4163,9 @@ static int CmdT55xxSniff(const char *Cmd) {
blockAddr |= 1;
}
have_data = true;
sprintf(modeText, "Default pwd write");
sprintf(pwdText, "%08X", usedPassword);
sprintf(dataText, "%08X", blockData);
modeText = "Default pwd write";
snprintf(pwdText, sizeof(pwdText), "%08X", usedPassword);
snprintf(dataText, sizeof(dataText), "%08X", blockData);
}
// Default Write (or password read ??)
@@ -4185,8 +4187,8 @@ static int CmdT55xxSniff(const char *Cmd) {
blockAddr |= 1;
}
have_data = true;
sprintf(modeText, "Default write");
sprintf(dataText, "%08X", blockData);
modeText = "Default write";
snprintf(dataText, sizeof(dataText), "%08X", blockData);
}
}
}
@@ -4221,9 +4223,9 @@ static int CmdT55xxSniff(const char *Cmd) {
blockAddr |= 1;
}
have_data = true;
sprintf(modeText, "Leading 0 pwd write");
sprintf(pwdText, "%08X", usedPassword);
sprintf(dataText, "%08X", blockData);
modeText = "Leading 0 pwd write";
snprintf(pwdText, sizeof(pwdText), "%08X", usedPassword);
snprintf(dataText, sizeof(dataText), "%08X", blockData);
}
}
}