From d3ec9c243815076d2d17e0db815b985bc844c10d Mon Sep 17 00:00:00 2001 From: Aram Date: Sat, 30 Apr 2016 23:17:51 +0200 Subject: [PATCH] Error handling --- libnfc_crypto1_crack.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libnfc_crypto1_crack.c b/libnfc_crypto1_crack.c index eebb7db..937e951 100644 --- a/libnfc_crypto1_crack.c +++ b/libnfc_crypto1_crack.c @@ -579,7 +579,8 @@ void * update_nonces_thread(void* v){ if (nfc_initiator_select_passive_target(pnd,nmMifare,NULL,0,&target)) { nested_auth(uid, known_key, ab_key, for_block, target_block, target_key, fp); } else { - printf("Don't move the tag!\n"); + printf("\rDon't move the tag!"); + fflush(stdout); } if(total_states){ char c; @@ -629,8 +630,10 @@ int main (int argc, const char * argv[]) { } if(!uid){ + fprintf(stderr, "No tag detected!\n"); // Disconnect from NFC device nfc_close(pnd); + return 1; } if(argc < 4){ @@ -673,8 +676,10 @@ int main (int argc, const char * argv[]) { nfc_close(pnd); space = craptev1_get_space(nonces, 95, uid); - total_states = craptev1_sizeof_space(space); - if(!space || !total_states){ + if(space){ + total_states = craptev1_sizeof_space(space); + } + if(!total_states){ fprintf(stderr, "No solution found!\n"); return 1; }