From 33c795d0bd0ba50616072a806fd5b38e1e2ccaef Mon Sep 17 00:00:00 2001 From: marshmellow42 Date: Sun, 14 Feb 2016 11:07:16 -0500 Subject: [PATCH] add check to fread call --- client/cmdhficlass.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/cmdhficlass.c b/client/cmdhficlass.c index 6c85e1c1..59b0ddc3 100644 --- a/client/cmdhficlass.c +++ b/client/cmdhficlass.c @@ -1046,7 +1046,11 @@ int CmdHFiClassCloneTag(const char *Cmd) { // else we have to create a share memory int i; fseek(f,startblock*8,SEEK_SET); - fread(tag_data,sizeof(iclass_block_t),endblock - startblock + 1,f); + if ( fread(tag_data,sizeof(iclass_block_t),endblock - startblock + 1,f) == 0 ) { + PrintAndLog("File reading error."); + fclose(f); + return 2; + } uint8_t MAC[4]={0x00,0x00,0x00,0x00}; uint8_t div_key[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; -- 2.39.5