[rtems commit] testsuites/fstests: Fix uninitialized utimbuf structs

Joel Sherrill joel at rtems.org
Mon Oct 4 22:36:16 UTC 2021


Module:    rtems
Branch:    master
Commit:    772ffc070455bdfe7a5e0970bf34655e5cf51fb8
Changeset: http://git.rtems.org/rtems/commit/?id=772ffc070455bdfe7a5e0970bf34655e5cf51fb8

Author:    Alex White <alex.white at oarcorp.com>
Date:      Mon Oct  4 14:24:02 2021 -0500

testsuites/fstests: Fix uninitialized utimbuf structs

The utimbuf structs in fsimfsconfig01 and fsimfsconfig02 were
being passed to utime uninitialized. This did not cause problems until
utime was changed to use utimensat behind the scenes. Now that
utimensat is called, the values of the utimbuf struct are checked, and
EINVAL is set for invalid values. The utimebuf structs in these tests
could contain invalid values since they are uninitialized.

By zero-initializing the utimbuf structs, we ensure that they pass the
checks in utimensat and that errno is set to the expected ENOTSUP.

---

 testsuites/fstests/fsimfsconfig01/init.c | 2 +-
 testsuites/fstests/fsimfsconfig03/init.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/testsuites/fstests/fsimfsconfig01/init.c b/testsuites/fstests/fsimfsconfig01/init.c
index fd11329..c3e4485 100644
--- a/testsuites/fstests/fsimfsconfig01/init.c
+++ b/testsuites/fstests/fsimfsconfig01/init.c
@@ -39,7 +39,7 @@ static const IMFS_node_control node_control = IMFS_GENERIC_INITIALIZER(
 
 static void Init(rtems_task_argument arg)
 {
-  struct utimbuf times;
+  const struct utimbuf times = {0};
   const char *generic = "generic";
   const char *mnt = "mnt";
   const char *dev = "device";
diff --git a/testsuites/fstests/fsimfsconfig03/init.c b/testsuites/fstests/fsimfsconfig03/init.c
index 32db163..beccb0f 100644
--- a/testsuites/fstests/fsimfsconfig03/init.c
+++ b/testsuites/fstests/fsimfsconfig03/init.c
@@ -38,7 +38,7 @@ static const IMFS_node_control node_control = IMFS_GENERIC_INITIALIZER(
 
 static void Init(rtems_task_argument arg)
 {
-  struct utimbuf times;
+  const struct utimbuf times = {0};
   const char *generic = "generic";
   const char *mnt = "mnt";
   const char *dev = "device";



More information about the vc mailing list