mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-02-24 23:54:42 +08:00
replaced the getline which does't support by minGW on windows
This commit is contained in:
parent
aea4d76687
commit
99a71a0d01
1 changed files with 14 additions and 10 deletions
|
@ -712,6 +712,7 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
{
|
{
|
||||||
FILE * f;
|
FILE * f;
|
||||||
char filename[256]={0};
|
char filename[256]={0};
|
||||||
|
uint8_t buf[13];
|
||||||
uint8_t *keyBlock = NULL, *p;
|
uint8_t *keyBlock = NULL, *p;
|
||||||
uint8_t stKeyBlock = 20;
|
uint8_t stKeyBlock = 20;
|
||||||
|
|
||||||
|
@ -810,20 +811,24 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * line = NULL;
|
|
||||||
size_t len = 0;
|
|
||||||
ssize_t read;
|
|
||||||
if ( (f = fopen( filename , "r")) ) {
|
if ( (f = fopen( filename , "r")) ) {
|
||||||
while((read = getline(&line, &len, f)) != -1){
|
while( !feof(f) ){
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
fgets(buf, sizeof(buf), f);
|
||||||
|
|
||||||
if( line[0]=='#' || line[0]=='\n' ) continue; //The line start with # is remcommnet,skip
|
if (strlen(buf) < 12 || buf[11] == '\n')
|
||||||
|
continue;
|
||||||
|
|
||||||
if (read < 12 || !isxdigit(line[0])){
|
while (fgetc(f) != '\n' && !feof(f)) ; //goto next line
|
||||||
PrintAndLog("File content error. '%s' must include 12 HEX symbols",line);
|
|
||||||
|
if( buf[0]=='#' ) continue; //The line start with # is remcommnet,skip
|
||||||
|
|
||||||
|
if (!isxdigit(buf[0])){
|
||||||
|
PrintAndLog("File content error. '%s' must include 12 HEX symbols",buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
line[12] = 0;
|
buf[12] = 0;
|
||||||
|
|
||||||
if ( stKeyBlock - keycnt < 2) {
|
if ( stKeyBlock - keycnt < 2) {
|
||||||
p = realloc(keyBlock, 6*(stKeyBlock+=10));
|
p = realloc(keyBlock, 6*(stKeyBlock+=10));
|
||||||
|
@ -835,11 +840,10 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
keyBlock = p;
|
keyBlock = p;
|
||||||
}
|
}
|
||||||
memset(keyBlock + 6 * keycnt, 0, 6);
|
memset(keyBlock + 6 * keycnt, 0, 6);
|
||||||
num_to_bytes(strtoll(line, NULL, 16), 6, keyBlock + 6*keycnt);
|
num_to_bytes(strtoll(buf, NULL, 16), 6, keyBlock + 6*keycnt);
|
||||||
PrintAndLog("chk custom key[%d] %012llx", keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));
|
PrintAndLog("chk custom key[%d] %012llx", keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));
|
||||||
keycnt++;
|
keycnt++;
|
||||||
}
|
}
|
||||||
free(line);
|
|
||||||
} else {
|
} else {
|
||||||
PrintAndLog("File: %s: not found or locked.", filename);
|
PrintAndLog("File: %s: not found or locked.", filename);
|
||||||
free(keyBlock);
|
free(keyBlock);
|
||||||
|
|
Loading…
Reference in a new issue