mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-24 17:11:28 +08:00
strdup
This commit is contained in:
parent
731f6fc322
commit
eb4573b06c
3 changed files with 21 additions and 11 deletions
|
@ -10,9 +10,10 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include <limits.h>
|
||||
#include <stdio.h> // for Mingw readline
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h> // for Mingw readline
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
@ -27,7 +28,6 @@
|
|||
#include "fileutils.h"
|
||||
#include "flash.h"
|
||||
|
||||
|
||||
static void showBanner(void) {
|
||||
g_printAndLog = PRINTANDLOG_PRINT;
|
||||
|
||||
|
@ -169,13 +169,16 @@ check_script:
|
|||
// remove linebreaks
|
||||
strcleanrn(script_cmd_buf, sizeof(script_cmd_buf));
|
||||
|
||||
if ((cmd = strmcopy(script_cmd_buf)) != NULL)
|
||||
cmd = strdup(script_cmd_buf);
|
||||
if (cmd != NULL)
|
||||
printprompt = true;
|
||||
}
|
||||
} else {
|
||||
// If there is a script command
|
||||
if (execCommand) {
|
||||
if ((cmd = strmcopy(script_cmd)) != NULL)
|
||||
|
||||
cmd = strdup(script_cmd);
|
||||
if (cmd != NULL)
|
||||
printprompt = true;
|
||||
|
||||
uint16_t len = strlen(script_cmd) + 1;
|
||||
|
@ -203,7 +206,8 @@ check_script:
|
|||
// remove linebreaks
|
||||
strcleanrn(script_cmd_buf, sizeof(script_cmd_buf));
|
||||
|
||||
if ((cmd = strmcopy(script_cmd_buf)) != NULL)
|
||||
cmd = strdup(script_cmd_buf);
|
||||
if (cmd != NULL)
|
||||
printprompt = true;
|
||||
|
||||
} else {
|
||||
|
|
|
@ -918,11 +918,16 @@ void strcreplace(char *buf, size_t len, char from, char to) {
|
|||
}
|
||||
}
|
||||
|
||||
char *strmcopy(const char *src) {
|
||||
int len = strlen(src) + 1;
|
||||
char *dest = (char *) calloc(len, sizeof(uint8_t));
|
||||
|
||||
char *strdup(const char *src) {
|
||||
return strndup(src, strlen(src));
|
||||
}
|
||||
char *strndup(const char *src, size_t len) {
|
||||
|
||||
char *dest = (char *) calloc(len + 1, sizeof(uint8_t));
|
||||
if (dest != NULL) {
|
||||
strncat(dest, src, len);
|
||||
memcpy(dest, src, len);
|
||||
dest[len] = '\0';
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ bool str_endswith(const char *s, const char *suffix); // check for suffix in
|
|||
void clean_ascii(unsigned char *buf, size_t len);
|
||||
void strcleanrn(char *buf, size_t len);
|
||||
void strcreplace(char *buf, size_t len, char from, char to);
|
||||
char *strmcopy(const char *src);
|
||||
char *strdup(const char *src);
|
||||
char *strndup(const char *src, size_t len);
|
||||
int hexstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue