From a67f5e204d47e6e61c2471c722e4ea7a3badf133 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 23 Jan 2023 09:40:53 -0500 Subject: [PATCH 1/2] Fix #1173, separate append on volume_name to system_mountpt Generating the system_mountpt string via a single call to snprintf triggered a compiler warning about overlapping memory. However this does not seem like a real warning, as the volume_name should always be null terminated before the overlap would be possible. By separating this to be a separate append of the volume_name along with an explicit size check to ensure the buffers indeed do not overlap, this avoids the warning. --- src/os/posix/src/os-impl-filesys.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/os/posix/src/os-impl-filesys.c b/src/os/posix/src/os-impl-filesys.c index fb6ff722a..d2d5c6c8d 100644 --- a/src/os/posix/src/os-impl-filesys.c +++ b/src/os/posix/src/os-impl-filesys.c @@ -43,6 +43,7 @@ #include "os-posix.h" #include "os-shared-filesys.h" #include "os-shared-idmap.h" +#include "os-shared-common.h" /**************************************************************************************** DEFINES @@ -84,6 +85,8 @@ int32 OS_FileSysStartVolume_Impl(const OS_object_token_t *token) OS_filesys_internal_record_t *local; struct stat stat_buf; const char * tmpdir; + size_t mplen; + size_t vollen; uint32 i; enum { @@ -168,7 +171,24 @@ int32 OS_FileSysStartVolume_Impl(const OS_object_token_t *token) return OS_FS_ERR_DRIVE_NOT_CREATED; } - snprintf(local->system_mountpt, sizeof(local->system_mountpt), "%s/osal:%s", tmpdir, local->volume_name); + /* + * Note - performing the concatenation in a single snprintf() call seems + * to trigger a (false) pointer overlap warning, because volume_name should + * always be null terminated. To get around this, calculate the + * string size and check that it is within the expected size, and do the + * append of volume_name explicitly. + */ + mplen = snprintf(local->system_mountpt, sizeof(local->system_mountpt), "%s/osal:", tmpdir); + if (mplen < sizeof(local->system_mountpt)) + { + vollen = OS_strnlen(local->volume_name, sizeof(local->volume_name)); + if ((vollen + mplen) >= sizeof(local->system_mountpt)) + { + vollen = sizeof(local->system_mountpt) - mplen - 1; + } + memcpy(&local->system_mountpt[mplen], local->volume_name, vollen); + local->system_mountpt[mplen + vollen] = 0; + } } return OS_SUCCESS; From dff5e0f94192f1851f62f81c2cd785b520a1401c Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 26 Jan 2023 14:36:41 -0500 Subject: [PATCH 2/2] Bump to v6.0.0-rc4+dev184 --- CHANGELOG.md | 4 ++++ src/os/inc/osapi-version.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca57cb2ae..8b1133ebb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Development Build: v6.0.0-rc4+dev184 +- separate append on volume_name to system_mountpt +- See + ## Development Build: v6.0.0-rc4+dev179 - Remove obsolete _USING_RTEMS_INCLUDES_ - Support adding default flags at task creation diff --git a/src/os/inc/osapi-version.h b/src/os/inc/osapi-version.h index 1943f890f..98ac8a543 100644 --- a/src/os/inc/osapi-version.h +++ b/src/os/inc/osapi-version.h @@ -34,7 +34,7 @@ /* * Development Build Macro Definitions */ -#define OS_BUILD_NUMBER 179 +#define OS_BUILD_NUMBER 183 #define OS_BUILD_BASELINE "v6.0.0-rc4" /*