From 3c4061697950f897e195dd77b6e471ca462dd3fb Mon Sep 17 00:00:00 2001
From: iceman1001 <iceman@iuse.se>
Date: Tue, 12 Jan 2016 22:57:23 +0100
Subject: [PATCH] FIX: Coverity, Dereference null return,  CID #212329, 
 filehandle could be NULL

---
 client/cmdhficlass.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/client/cmdhficlass.c b/client/cmdhficlass.c
index 22d443f8..d0184335 100644
--- a/client/cmdhficlass.c
+++ b/client/cmdhficlass.c
@@ -374,12 +374,15 @@ int CmdHFiClassDecrypt(const char *Cmd) {
 	//Open the tagdump-file
 	FILE *f;
 	char filename[FILE_PATH_SIZE];
-	if(opt == 'f' && param_getstr(Cmd, 1, filename) > 0)
-	{
-		f = fopen(filename, "rb");
-	}else{
+	if(opt == 'f' && param_getstr(Cmd, 1, filename) > 0) {
+		if ( (f = fopen(filename, "rb")) == NULL) {
+			PrintAndLog("Could not find file %s", filename);
+			return 1;
+		}
+		
+	} else {
 		return usage_hf_iclass_decrypt();
-	}
+	}	
 
 	fseek(f, 0, SEEK_END);
 	long fsize = ftell(f);
-- 
2.39.5