chg: added limit check for loadfile

rename: 'lf hitag checkchallenges'  ->  'lf hitag cc'
chg: 'lf hitag checkchallenges' - refactored, added helptext
This commit is contained in:
iceman1001 2019-03-14 08:24:49 +01:00
commit 7d88c22aaf
5 changed files with 85 additions and 51 deletions

View file

@ -269,7 +269,7 @@ out:
return retval;
}
int loadFile(const char *preferredName, const char *suffix, void *data, size_t *datalen) {
int loadFile(const char *preferredName, const char *suffix, void *data, size_t maxdatalen, size_t *datalen) {
if (preferredName == NULL) return 1;
if (suffix == NULL) return 1;
@ -313,6 +313,11 @@ int loadFile(const char *preferredName, const char *suffix, void *data, size_t *
retval = 3;
goto out;
}
if ( bytes_read != maxdatalen ) {
PrintAndLogDevice(WARNING, "Warning, bytes read exeed calling array limit. Max bytes is %d bytes", maxdatalen);
bytes_read = maxdatalen;
}
memcpy((data), dump, bytes_read);
free(dump);