Merge branch 'master' into argtable

This commit is contained in:
Oleg Moiseenko 2018-01-03 17:53:33 +02:00 committed by GitHub
commit b761cb0a46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 76 additions and 70 deletions

View file

@ -232,8 +232,8 @@ test_script:
#--- end Job
[bool]$res=$false
# Wait 40 sec timeout for Job
if(Wait-Job $Job -Timeout 40){
# Wait 120 sec timeout for Job
if(Wait-Job $Job -Timeout 120){
$Results = $Job | Receive-Job
if($Results -like "true"){
$res=$true
@ -278,6 +278,11 @@ test_script:
ExecTest "hf mf hardnested" "hf mf hardnested" {bash -lc "cd ~/client;proxmark3 comx -c 'hf mf hardnested t 1 000000000000'"} "found:"
#proxmark crypto tests
ExecTest "hf emv test" "hf emv test" {bash -lc "cd ~/client;proxmark3 comx -c 'hf emv test'"} "Tests ?OK"
if ($global:TestsPassed) {
Write-Host "Tests [ OK ]" -ForegroundColor Green
} else {

View file

@ -40,14 +40,14 @@ int split(char *str, char *arr[MAX_ARGS]){
int wordCnt = 0;
while(1){
while(isspace(str[beginIndex])){
while(isspace((unsigned char)str[beginIndex])){
++beginIndex;
}
if(str[beginIndex] == '\0') {
break;
}
endIndex = beginIndex;
while (str[endIndex] && !isspace(str[endIndex])){
while (str[endIndex] && !isspace((unsigned char)str[endIndex])){
++endIndex;
}
int len = endIndex - beginIndex;

View file

@ -16,6 +16,7 @@
#include <inttypes.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include "util.h"
#include "util_posix.h"
#include "iso14443crc.h"
@ -748,9 +749,9 @@ int CmdHF14AAPDU(const char *cmd) {
// len = data + PCB(1b) + CRC(2b)
CLIGetStrBLessWithReturn(4, data, &datalen, 1 + 2);
CLIParserFree();
// PrintAndLog("---str [%d] %s", arg_get_str(4)->count, arg_get_str(4)->sval[0]);
PrintAndLog(">>>>[%s%s%s] %s", activateField ? "sel ": "", leaveSignalON ? "keep ": "", decodeTLV ? "TLV": "", sprint_hex(data, datalen));
int res = ExchangeAPDU14a(data, datalen, activateField, leaveSignalON, data, USB_CMD_DATA_SIZE, &datalen);

View file

@ -987,6 +987,7 @@ int CmdHF14AMfChk(const char *Cmd)
int i, res;
int keycnt = 0;
char ctmp = 0x00;
int clen = 0;
char ctmp3[3] = {0x00};
uint8_t blockNo = 0;
uint8_t SectorsCnt = 0;
@ -1015,6 +1016,8 @@ int CmdHF14AMfChk(const char *Cmd)
blockNo = param_get8(Cmd, 0);
ctmp = param_getchar(Cmd, 1);
clen = param_getlength(Cmd, 1);
if (clen == 1) {
switch (ctmp) {
case 'a': case 'A':
keyType = 0;
@ -1030,17 +1033,19 @@ int CmdHF14AMfChk(const char *Cmd)
free(keyBlock);
return 1;
};
}
// transfer to emulator & create dump file
ctmp = param_getchar(Cmd, 2);
if (ctmp == 't' || ctmp == 'T') transferToEml = 1;
if (ctmp == 'd' || ctmp == 'D') createDumpFile = 1;
clen = param_getlength(Cmd, 2);
if (clen == 1 && (ctmp == 't' || ctmp == 'T')) transferToEml = 1;
if (clen == 1 && (ctmp == 'd' || ctmp == 'D')) createDumpFile = 1;
param3InUse = transferToEml | createDumpFile;
timeout14a = 500; // fast by default
// double parameters - ts, ds
int clen = param_getlength(Cmd, 2);
clen = param_getlength(Cmd, 2);
if (clen == 2 || clen == 3){
param_getstr(Cmd, 2, ctmp3, sizeof(ctmp3));
ctmp = ctmp3[1];
@ -1089,7 +1094,7 @@ int CmdHF14AMfChk(const char *Cmd)
if( buf[0]=='#' ) continue; //The line start with # is comment, skip
if (!isxdigit(buf[0])){
if (!isxdigit((unsigned char)buf[0])){
PrintAndLog("File content error. '%s' must include 12 HEX symbols",buf);
continue;
}

View file

@ -1433,7 +1433,7 @@ int CmdT55xxBruteForce(const char *Cmd) {
//The line start with # is comment, skip
if( buf[0]=='#' ) continue;
if (!isxdigit(buf[0])) {
if (!isxdigit((unsigned char)buf[0])) {
PrintAndLog("File content error. '%s' must include 8 HEX symbols", buf);
continue;
}

View file

@ -172,7 +172,7 @@ bool WaitForResponseTimeoutW(uint32_t cmd, UsbCommand* response, size_t ms_timeo
if (msclock() - start_time > 2000 && show_warning) {
PrintAndLog("Waiting for a response from the proxmark...");
PrintAndLog("Don't forget to cancel its operation first by pressing on the button");
break;
show_warning = false;
}
}
return false;

View file

@ -76,8 +76,11 @@ int CmdList(const char *Cmd)
{
DIR *dp;
struct dirent *ep;
char script_directory_path[strlen(get_my_executable_directory()) + strlen(LUA_SCRIPTS_DIRECTORY) + 1];
strcpy(script_directory_path, get_my_executable_directory());
char const * exedir = get_my_executable_directory();
if (exedir == NULL)
return 0;
char script_directory_path[strlen(exedir) + strlen(LUA_SCRIPTS_DIRECTORY) + 1];
strcpy(script_directory_path, exedir);
strcat(script_directory_path, LUA_SCRIPTS_DIRECTORY);
dp = opendir(script_directory_path);

View file

@ -8,6 +8,7 @@
// EMV commands
//-----------------------------------------------------------------------------
#include <ctype.h>
#include "cmdemv.h"
#include "test/cryptotest.h"
@ -69,7 +70,7 @@ int CmdHFEMVSelect(const char *cmd) {
return 1;
}
if (isxdigit(c)) {
if (isxdigit((unsigned char)c)) {
switch(param_gethex_to_eol(cmd, cmdp, data, sizeof(data), &datalen)) {
case 1:
PrintAndLog("Invalid HEX value.");

View file

@ -22,7 +22,7 @@
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* by the Free Software Foundation, or, at your option, any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -33,7 +33,6 @@
* along with loclass. If not, see <http://www.gnu.org/licenses/>.
*
*
*
****************************************************************************/

View file

@ -22,7 +22,7 @@
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* by the Free Software Foundation, or, at your option, any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -33,7 +33,6 @@
* along with loclass. If not, see <http://www.gnu.org/licenses/>.
*
*
*
****************************************************************************/

View file

@ -22,7 +22,7 @@
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* by the Free Software Foundation, or, at your option, any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -33,7 +33,6 @@
* along with loclass. If not, see <http://www.gnu.org/licenses/>.
*
*
*
****************************************************************************/
#include <stdint.h>

View file

@ -22,7 +22,7 @@
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* by the Free Software Foundation, or, at your option, any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -33,7 +33,6 @@
* along with loclass. If not, see <http://www.gnu.org/licenses/>.
*
*
*
****************************************************************************/

View file

@ -22,7 +22,7 @@
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* by the Free Software Foundation, or, at your option, any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -33,7 +33,6 @@
* along with loclass. If not, see <http://www.gnu.org/licenses/>.
*
*
*
****************************************************************************/
#include <stdint.h>

View file

@ -22,7 +22,7 @@
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* by the Free Software Foundation, or, at your option, any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -33,7 +33,6 @@
* along with loclass. If not, see <http://www.gnu.org/licenses/>.
*
*
*
****************************************************************************/

View file

@ -22,7 +22,7 @@
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* by the Free Software Foundation, or, at your option, any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -33,7 +33,6 @@
* along with loclass. If not, see <http://www.gnu.org/licenses/>.
*
*
*
****************************************************************************/
#ifndef ON_DEVICE

View file

@ -22,7 +22,7 @@
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* by the Free Software Foundation, or, at your option, any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -33,7 +33,6 @@
* along with loclass. If not, see <http://www.gnu.org/licenses/>.
*
*
*
****************************************************************************/
#ifndef FILEUTILS_H

View file

@ -22,7 +22,7 @@
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* by the Free Software Foundation, or, at your option, any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -33,7 +33,6 @@
* along with loclass. If not, see <http://www.gnu.org/licenses/>.
*
*
*
****************************************************************************/
/**
@ -740,18 +739,16 @@ int readKeyFile(uint8_t key[8])
FILE *f;
int retval = 1;
f = fopen("iclass_key.bin", "rb");
if (f)
{
if(fread(key, sizeof(uint8_t), 8, f) == 1)
{
if (!f)
return retval;
if (fread(key, sizeof(uint8_t), 8, f) == 8) {
retval = 0;
}
fclose(f);
}
return retval;
}
int doKeyTests(uint8_t debuglevel)
{
debug_print = debuglevel;

View file

@ -22,7 +22,7 @@
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* by the Free Software Foundation, or, at your option, any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -33,7 +33,6 @@
* along with loclass. If not, see <http://www.gnu.org/licenses/>.
*
*
*
****************************************************************************/
#ifndef IKEYS_H

View file

@ -22,7 +22,7 @@
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* by the Free Software Foundation, or, at your option, any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -33,7 +33,6 @@
* along with loclass. If not, see <http://www.gnu.org/licenses/>.
*
*
*
****************************************************************************/

View file

@ -306,7 +306,7 @@ static int l_pack(lua_State *L) /** pack(f,...) */
sbyte = 0;
odd = 0;
}
} else if (isspace(a[ii])) {
} else if (isspace((unsigned char)a[ii])) {
/* ignore */
} else {
/* err ... ignore too*/

View file

@ -596,7 +596,7 @@ mbynam(model_t *dest, const char *key) {
uerror("cannot allocate memory for comparison string");
akey.name = uptr = ukey;
do
*uptr++ = toupper(*key);
*uptr++ = toupper((unsigned char)*key);
while(*key++);
aptr = bsearch(&akey, aliases, NALIASES, sizeof(struct malias), (int (*)(const void *, const void *)) &acmp);

View file

@ -9,12 +9,14 @@
// UI utilities
//-----------------------------------------------------------------------------
#include <stdarg.h>
#include <stdbool.h>
#ifndef EXTERNAL_PRINTANDLOG
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdarg.h>
#include <readline/readline.h>
#include <pthread.h>
#endif
#include "ui.h"
@ -26,10 +28,12 @@ int GridOffset = 0;
bool GridLocked = false;
bool showDemod = true;
extern pthread_mutex_t print_lock;
static char *logfilename = "proxmark3.log";
#ifndef EXTERNAL_PRINTANDLOG
// Declared in proxmark3.c
extern pthread_mutex_t print_lock;
void PrintAndLog(char *fmt, ...)
{
char *saved_line;
@ -94,7 +98,7 @@ void PrintAndLog(char *fmt, ...)
//release lock
pthread_mutex_unlock(&print_lock);
}
#endif
void SetLogFilename(char *fn)
{

View file

@ -496,7 +496,7 @@ int param_gethex(const char *line, int paramnum, uint8_t * data, int hexcnt)
return 1;
for(i = 0; i < hexcnt; i += 2) {
if (!(isxdigit(line[bg + i]) && isxdigit(line[bg + i + 1])) ) return 1;
if (!(isxdigit((unsigned char)line[bg + i]) && isxdigit((unsigned char)line[bg + i + 1])) ) return 1;
sscanf((char[]){line[bg + i], line[bg + i + 1], 0}, "%X", &temp);
data[i / 2] = temp & 0xff;
@ -518,7 +518,7 @@ int param_gethex_ex(const char *line, int paramnum, uint8_t * data, int *hexcnt)
return 1;
for(i = 0; i < *hexcnt; i += 2) {
if (!(isxdigit(line[bg + i]) && isxdigit(line[bg + i + 1])) ) return 1;
if (!(isxdigit((unsigned char)line[bg + i]) && isxdigit((unsigned char)line[bg + i + 1])) ) return 1;
sscanf((char[]){line[bg + i], line[bg + i + 1], 0}, "%X", &temp);
data[i / 2] = temp & 0xff;
@ -543,7 +543,7 @@ int param_gethex_to_eol(const char *line, int paramnum, uint8_t * data, int maxd
continue;
}
if (isxdigit(line[indx])) {
if (isxdigit((unsigned char)line[indx])) {
buf[strlen(buf) + 1] = 0x00;
buf[strlen(buf)] = line[indx];
} else {
@ -620,7 +620,7 @@ int hextobinarray(char *target, char *source)
else if (x >= 'A' && x <= 'F')
x -= 'A' - 10;
else {
printf("Discovered unknown character %c %d at idx %d of %s\n", x, x, source - start, start);
printf("Discovered unknown character %c %d at idx %tu of %s\n", x, x, source - start, start);
return 0;
}
// output