Move from memset to memset_s.
This adds the extra bounds checks and panics if there is a violation.
Change-Id: I9db3ca44be4f9c39964d912b57fe7b68e2792bc1
diff --git a/test/hftest/hftest_common.c b/test/hftest/hftest_common.c
index e1b4602..4a3f0df 100644
--- a/test/hftest/hftest_common.c
+++ b/test/hftest/hftest_common.c
@@ -106,8 +106,7 @@
}
/*
* It's easier to put the comma at the start of the line
- * than the end even
- * though the JSON looks a bit funky.
+ * than the end even though the JSON looks a bit funky.
*/
HFTEST_LOG(" %c\"%s\"",
tests_in_suite ? ',' : ' ', test->name);
@@ -136,7 +135,7 @@
{
/* Prepare the context. */
struct hftest_context *ctx = hftest_get_context();
- memset(ctx, 0, sizeof(*ctx));
+ memset_s(ctx, sizeof(*ctx), 0, sizeof(*ctx));
ctx->abort = abort;
/* Run any set up functions. */
diff --git a/test/hftest/hftest_service.c b/test/hftest/hftest_service.c
index b110cb5..c728e27 100644
--- a/test/hftest/hftest_service.c
+++ b/test/hftest/hftest_service.c
@@ -107,7 +107,7 @@
/* Clean the context. */
ctx = hftest_get_context();
- memset(ctx, 0, sizeof(*ctx));
+ memset_s(ctx, sizeof(*ctx), 0, sizeof(*ctx));
ctx->abort = abort;
ctx->send = (struct spci_message *)send;
ctx->recv = (struct spci_message *)recv;
diff --git a/test/vmapi/primary_with_secondaries/memory_sharing.c b/test/vmapi/primary_with_secondaries/memory_sharing.c
index c74d6f3..fc03a32 100644
--- a/test/vmapi/primary_with_secondaries/memory_sharing.c
+++ b/test/vmapi/primary_with_secondaries/memory_sharing.c
@@ -93,7 +93,7 @@
SERVICE_SELECT(SERVICE_VM0, "memory_increment", mb.send);
- memset(ptr, 'a', PAGE_SIZE);
+ memset_s(ptr, sizeof(page), 'a', PAGE_SIZE);
ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_SHARE),
0);
@@ -136,7 +136,7 @@
SERVICE_SELECT(SERVICE_VM0, "memory_return", mb.send);
/* Dirty the memory before sharing it. */
- memset(ptr, 'b', PAGE_SIZE);
+ memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_SHARE),
0);
@@ -174,7 +174,7 @@
SERVICE_SELECT(SERVICE_VM0, "memory_return", mb.send);
/* Dirty the memory before giving it. */
- memset(ptr, 'b', PAGE_SIZE);
+ memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_GIVE),
0);
@@ -212,7 +212,7 @@
SERVICE_SELECT(SERVICE_VM0, "memory_return", mb.send);
/* Dirty the memory before lending it. */
- memset(ptr, 'c', PAGE_SIZE);
+ memset_s(ptr, sizeof(page), 'c', PAGE_SIZE);
ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
HF_MEMORY_LEND),
0);