mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
safer string copy
This commit is contained in:
parent
4da12a6089
commit
3b792f8b04
2 changed files with 7 additions and 7 deletions
|
@ -918,13 +918,13 @@ void strcreplace(char *buf, size_t len, char from, char to) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *strmcopy(const char *buf) {
|
char *strmcopy(const char *src) {
|
||||||
char *str = (char *) calloc(strlen(buf) + 1, sizeof(uint8_t));
|
char *dest = (char *) calloc(strlen(src) + 1, sizeof(uint8_t));
|
||||||
if (str != NULL) {
|
if (dest != NULL) {
|
||||||
memset(str, 0, strlen(buf) + 1);
|
memset(dest, 0, strlen(src) + 1);
|
||||||
strcpy(str, buf);
|
strncat(dest, src, strlen(src));
|
||||||
}
|
}
|
||||||
return str;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -99,6 +99,6 @@ bool str_endswith(const char *s, const char *suffix); // check for suffix in
|
||||||
void clean_ascii(unsigned char *buf, size_t len);
|
void clean_ascii(unsigned char *buf, size_t len);
|
||||||
void strcleanrn(char *buf, size_t len);
|
void strcleanrn(char *buf, size_t len);
|
||||||
void strcreplace(char *buf, size_t len, char from, char to);
|
void strcreplace(char *buf, size_t len, char from, char to);
|
||||||
char *strmcopy(const char *buf);
|
char *strmcopy(const char *src);
|
||||||
int hexstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str);
|
int hexstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue