Merge pull request #3699 from s00se/replace-deprecated-strtok-with-strtok_r
client: replace deprecated strtok calls with strtok_r
This commit is contained in:
5 files changed
+36
-15
No files matched your search
@@ -15,6 +15,9 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Data and Graph commands
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _WIN32
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#endif
|
||||
#include "cmddata.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -3512,10 +3515,11 @@ static int CmdAtrLookup(const char *Cmd) {
|
||||
|
||||
char *copy = str_dup(getAtrInfo((char *)data));
|
||||
|
||||
char *token = strtok(copy, "\n");
|
||||
char *saveptr = NULL;
|
||||
char *token = strtok_r(copy, "\n", &saveptr);
|
||||
while (token != NULL) {
|
||||
PrintAndLogEx(INFO, " %s", token);
|
||||
token = strtok(NULL, "\n");
|
||||
token = strtok_r(NULL, "\n", &saveptr);
|
||||
}
|
||||
free(copy);
|
||||
return PM3_SUCCESS;
|
||||
@@ -3729,7 +3733,8 @@ static int CmdBinaryMap(const char *Cmd) {
|
||||
template[1] = 0;
|
||||
}
|
||||
|
||||
char *token = strtok((char *)template, ",");
|
||||
char *saveptr = NULL;
|
||||
char *token = strtok_r((char *)template, ",", &saveptr);
|
||||
|
||||
// header
|
||||
PrintAndLogEx(INFO, "---+-------------------------");
|
||||
@@ -3752,7 +3757,7 @@ static int CmdBinaryMap(const char *Cmd) {
|
||||
}
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
token = strtok(NULL, ",");
|
||||
token = strtok_r(NULL, ",", &saveptr);
|
||||
cnt++;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// High frequency ISO14443A commands
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef _WIN32
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#endif
|
||||
#include "cmdhf14a.h"
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
@@ -3399,10 +3402,11 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
||||
int atrLen = 0;
|
||||
atsToEmulatedAtr(card.ats, atr, &atrLen);
|
||||
char *copy = str_dup(getAtrInfo(sprint_hex_inrow(atr, atrLen)));
|
||||
char *token = strtok(copy, "\n");
|
||||
char *saveptr = NULL;
|
||||
char *token = strtok_r(copy, "\n", &saveptr);
|
||||
while (token != NULL) {
|
||||
PrintAndLogEx(SUCCESS, " %s", token);
|
||||
token = strtok(NULL, "\n");
|
||||
token = strtok_r(NULL, "\n", &saveptr);
|
||||
}
|
||||
free(copy);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
// High frequency ISO14443B commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _WIN32
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#endif
|
||||
#include "cmdhf14b.h"
|
||||
#include <ctype.h>
|
||||
#include "iso14b.h"
|
||||
@@ -494,10 +497,11 @@ static int print_atqb_resp(uint8_t *data, uint8_t cid) {
|
||||
int atrLen = 0;
|
||||
atqbToEmulatedAtr(data, cid, atr, &atrLen);
|
||||
char *copy = str_dup(getAtrInfo(sprint_hex_inrow(atr, atrLen)));
|
||||
char *token = strtok(copy, "\n");
|
||||
char *saveptr = NULL;
|
||||
char *token = strtok_r(copy, "\n", &saveptr);
|
||||
while (token != NULL) {
|
||||
PrintAndLogEx(SUCCESS, " %s", token);
|
||||
token = strtok(NULL, "\n");
|
||||
token = strtok_r(NULL, "\n", &saveptr);
|
||||
}
|
||||
free(copy);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
// EMV commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _WIN32
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#endif
|
||||
#include "cmdemv.h"
|
||||
#include <string.h>
|
||||
#include "comms.h" // DropField
|
||||
@@ -292,7 +295,8 @@ static int emv_parse_track1(const uint8_t *d, size_t n, bool verbose) {
|
||||
char *tmp = str_ndup((const char *)d, n);
|
||||
uint8_t i = 0;
|
||||
const char delim[2] = "^";
|
||||
char *token = strtok(tmp, delim);
|
||||
char *saveptr = NULL;
|
||||
char *token = strtok_r(tmp, delim, &saveptr);
|
||||
while (token != NULL) {
|
||||
|
||||
switch (i) {
|
||||
@@ -340,7 +344,7 @@ static int emv_parse_track1(const uint8_t *d, size_t n, bool verbose) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
token = strtok(0, delim);
|
||||
token = strtok_r(NULL, delim, &saveptr);
|
||||
i++;
|
||||
}
|
||||
free(tmp);
|
||||
@@ -3171,4 +3175,3 @@ int CmdEMV(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
return CmdsParse(CommandTable, Cmd);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
// NFC Data Exchange Format (NDEF) functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _WIN32
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#endif
|
||||
#include "ndef.h"
|
||||
|
||||
#include <string.h>
|
||||
@@ -1009,13 +1012,15 @@ static int ndefDecodeMime_vcard(NDEFHeader_t *ndef) {
|
||||
|
||||
char *s = strstr((char *)ndef->Payload, "PHOTO");
|
||||
if (s) {
|
||||
s = strtok(s, ";");
|
||||
char *saveptr = NULL;
|
||||
s = strtok_r(s, ";", &saveptr);
|
||||
while (s) {
|
||||
char *tmp = s;
|
||||
if (strncmp(tmp, "ENCODING", 8) == 0) {
|
||||
} else if (strncmp(tmp, "TYPE", 4) == 0) {
|
||||
|
||||
char *part = strtok(tmp + 4, ":");
|
||||
char *part_saveptr = NULL;
|
||||
char *part = strtok_r(tmp + 4, ":", &part_saveptr);
|
||||
while (part) {
|
||||
|
||||
if (strncmp(part, "=image/", 7) == 0) {
|
||||
@@ -1024,10 +1029,10 @@ static int ndefDecodeMime_vcard(NDEFHeader_t *ndef) {
|
||||
// should be in the BASE64 data part now.
|
||||
ShowBase64PictureWindow("VCARD photo", part);
|
||||
}
|
||||
part = strtok(NULL, ":");
|
||||
part = strtok_r(NULL, ":", &part_saveptr);
|
||||
}
|
||||
}
|
||||
s = strtok(NULL, ";");
|
||||
s = strtok_r(NULL, ";", &saveptr);
|
||||
}
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
|
||||
Reference in new issue
Block a user