summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2015-06-24 11:33:26 +0100
committerJose Fonseca <jfonseca@vmware.com>2015-06-24 11:34:05 +0100
commit5642f6578ec8ebcc73e1b9aa3826d37010a5b7ce (patch)
tree7dc736f7733d94921b32f94c13e7a943a517836c /cli
parent8b0807fc98700fdaf69ed880eab416e43194f219 (diff)
cli/sed: Avoid strcpy.
Diffstat (limited to 'cli')
-rw-r--r--cli/cli_sed.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/cli/cli_sed.cpp b/cli/cli_sed.cpp
index 1ad035b9..401b7a63 100644
--- a/cli/cli_sed.cpp
+++ b/cli/cli_sed.cpp
@@ -108,9 +108,10 @@ public:
void visit(String *node) {
if (!searchName.compare(node->value)) {
+ size_t len = replaceName.length() + 1;
delete [] node->value;
- char *str = new char [replaceName.length() + 1];
- strcpy(str, replaceName.c_str());
+ char *str = new char [len];
+ memcpy(str, replaceName.c_str(), len);
node->value = str;
}
}