mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-24 08:05:13 +08:00
fix coverity CID 322762
This commit is contained in:
parent
16c43bea2d
commit
dfd07ccd69
1 changed files with 13 additions and 10 deletions
|
@ -72,7 +72,7 @@ uint8_t cmds[8][2] = {
|
||||||
static int global_found = 0;
|
static int global_found = 0;
|
||||||
static int global_found_candidate = 0;
|
static int global_found_candidate = 0;
|
||||||
static uint64_t global_candiate_key = 0;
|
static uint64_t global_candiate_key = 0;
|
||||||
static size_t thread_count = 2;
|
static int thread_count = 2;
|
||||||
|
|
||||||
static int param_getptr(const char *line, int *bg, int *en, int paramnum) {
|
static int param_getptr(const char *line, int *bg, int *en, int paramnum) {
|
||||||
int i;
|
int i;
|
||||||
|
@ -384,13 +384,12 @@ static void *brute_thread(void *arguments) {
|
||||||
|
|
||||||
nt = count << 16 | prng_successor(count, 16);
|
nt = count << 16 | prng_successor(count, 16);
|
||||||
|
|
||||||
if (!candidate_nonce(args->xored, nt, args->ev1))
|
if (candidate_nonce(args->xored, nt, args->ev1) == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
p64 = prng_successor(nt, 64);
|
p64 = prng_successor(nt, 64);
|
||||||
ks2 = ar_enc ^ p64;
|
ks2 = ar_enc ^ p64;
|
||||||
ks3 = at_enc ^ prng_successor(p64, 32);
|
ks3 = at_enc ^ prng_successor(p64, 32);
|
||||||
free(revstate);
|
|
||||||
revstate = lfsr_recovery64(ks2, ks3);
|
revstate = lfsr_recovery64(ks2, ks3);
|
||||||
ks4 = crypto1_word(revstate, 0, 0);
|
ks4 = crypto1_word(revstate, 0, 0);
|
||||||
|
|
||||||
|
@ -415,14 +414,17 @@ static void *brute_thread(void *arguments) {
|
||||||
|
|
||||||
// check if cmd exists
|
// check if cmd exists
|
||||||
uint8_t isOK = checkValidCmd(decrypted);
|
uint8_t isOK = checkValidCmd(decrypted);
|
||||||
(void)isOK;
|
if (isOK == false) {
|
||||||
|
printf(_RED_("<-- not a valid cmd\n"));
|
||||||
|
pthread_mutex_unlock(&print_lock);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Add a crc-check.
|
// Add a crc-check.
|
||||||
isOK = checkCRC(decrypted);
|
isOK = checkCRC(decrypted);
|
||||||
if (isOK == false) {
|
if (isOK == false) {
|
||||||
printf(_RED_("<-- not a valid cmd\n"));
|
printf(_RED_("<-- not a valid crc\n"));
|
||||||
pthread_mutex_unlock(&print_lock);
|
pthread_mutex_unlock(&print_lock);
|
||||||
free(revstate);
|
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
printf("<-- valid cmd\n");
|
printf("<-- valid cmd\n");
|
||||||
|
@ -450,6 +452,7 @@ static void *brute_thread(void *arguments) {
|
||||||
free(revstate);
|
free(revstate);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
free(revstate);
|
||||||
}
|
}
|
||||||
free(args);
|
free(args);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -468,7 +471,7 @@ static void *brute_key_thread(void *arguments) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
key |= count << 32;
|
key |= (count << 32);
|
||||||
|
|
||||||
// Init cipher with key
|
// Init cipher with key
|
||||||
struct Crypto1State *pcs = crypto1_create(key);
|
struct Crypto1State *pcs = crypto1_create(key);
|
||||||
|
@ -576,7 +579,7 @@ int main(int argc, char *argv[]) {
|
||||||
thread_count = 2;
|
thread_count = 2;
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
printf("\nBruteforce using " _YELLOW_("%zu") " threads\n", thread_count);
|
printf("\nBruteforce using " _YELLOW_("%d") " threads\n", thread_count);
|
||||||
printf("looking for the last bytes of the encrypted tagnonce\n");
|
printf("looking for the last bytes of the encrypted tagnonce\n");
|
||||||
|
|
||||||
pthread_t threads[thread_count];
|
pthread_t threads[thread_count];
|
||||||
|
@ -585,7 +588,7 @@ int main(int argc, char *argv[]) {
|
||||||
pthread_mutex_init(&print_lock, NULL);
|
pthread_mutex_init(&print_lock, NULL);
|
||||||
|
|
||||||
// one thread T0 for none EV1.
|
// one thread T0 for none EV1.
|
||||||
struct thread_args *a = malloc(sizeof(struct thread_args));
|
struct thread_args *a = calloc(1, sizeof(struct thread_args));
|
||||||
a->xored = xored;
|
a->xored = xored;
|
||||||
a->thread = 0;
|
a->thread = 0;
|
||||||
a->idx = 0;
|
a->idx = 0;
|
||||||
|
@ -594,7 +597,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// the rest of available threads to EV1 scenario
|
// the rest of available threads to EV1 scenario
|
||||||
for (int i = 0; i < thread_count - 1; ++i) {
|
for (int i = 0; i < thread_count - 1; ++i) {
|
||||||
struct thread_args *b = malloc(sizeof(struct thread_args));
|
struct thread_args *b = calloc(1, sizeof(struct thread_args));
|
||||||
b->xored = xored;
|
b->xored = xored;
|
||||||
b->thread = i + 1;
|
b->thread = i + 1;
|
||||||
b->idx = i;
|
b->idx = i;
|
||||||
|
|
Loading…
Reference in a new issue