mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -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 *str = (char *) calloc(strlen(buf) + 1, sizeof(uint8_t));
|
||||
if (str != NULL) {
|
||||
memset(str, 0, strlen(buf) + 1);
|
||||
strcpy(str, buf);
|
||||
char *strmcopy(const char *src) {
|
||||
char *dest = (char *) calloc(strlen(src) + 1, sizeof(uint8_t));
|
||||
if (dest != NULL) {
|
||||
memset(dest, 0, strlen(src) + 1);
|
||||
strncat(dest, src, strlen(src));
|
||||
}
|
||||
return str;
|
||||
return dest;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue