Merge pull request #507 from jktjkt/Wstringop-truncation
Fix strncpy invocation in tests
diff --git a/tests/api/test_tree_data.c b/tests/api/test_tree_data.c
index da8ac1b..8b412af 100644
--- a/tests/api/test_tree_data.c
+++ b/tests/api/test_tree_data.c
@@ -1138,7 +1138,7 @@
int fd;
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -1181,7 +1181,7 @@
int fd;
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -1224,7 +1224,7 @@
int fd;
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -1268,7 +1268,7 @@
int fd;
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -1323,7 +1323,7 @@
int fd;
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -1378,7 +1378,7 @@
int fd = -1;
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
diff --git a/tests/api/test_tree_schema.c b/tests/api/test_tree_schema.c
index 03e22d1..16a8eea 100644
--- a/tests/api/test_tree_schema.c
+++ b/tests/api/test_tree_schema.c
@@ -817,7 +817,7 @@
}
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -867,7 +867,7 @@
}
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -917,7 +917,7 @@
}
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -968,7 +968,7 @@
}
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -1019,7 +1019,7 @@
}
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -1081,7 +1081,7 @@
}
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -1143,7 +1143,7 @@
}
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -1206,7 +1206,7 @@
}
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
diff --git a/tests/api/test_xml.c b/tests/api/test_xml.c
index 3df4ea0..32f2a7a 100644
--- a/tests/api/test_xml.c
+++ b/tests/api/test_xml.c
@@ -188,7 +188,7 @@
int fd;
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {
@@ -244,7 +244,7 @@
assert_string_equal("x", xml->name);
memset(file_name, 0, sizeof(file_name));
- strncpy(file_name, TMP_TEMPLATE, strlen(TMP_TEMPLATE));
+ strncpy(file_name, TMP_TEMPLATE, sizeof(file_name));
fd = mkstemp(file_name);
if (fd < 1) {