Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #455, correct length of device_name in filesys #464

Merged
merged 2 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/os/shared/inc/os-shared-filesys.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ typedef struct

typedef struct
{
char device_name[OS_MAX_API_NAME]; /**< The name of the underlying block device, if applicable */
char device_name[OS_FS_DEV_NAME_LEN]; /**< The name of the underlying block device, if applicable */
char volume_name[OS_FS_VOL_NAME_LEN];
char system_mountpt[OS_MAX_LOCAL_PATH_LEN]; /**< The name/prefix where the contents are accessible in the host operating system */
char virtual_mountpt[OS_MAX_PATH_LEN]; /**< The name/prefix in the OSAL Virtual File system exposed to applications */
Expand Down
4 changes: 2 additions & 2 deletions src/os/shared/src/osapi-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ int32 OS_FileSysAddFixedMap(uint32 *filesys_id, const char *phys_path, const cha
return OS_INVALID_POINTER;
}

if (strlen(phys_path) >= OS_MAX_PATH_LEN ||
if (strlen(phys_path) >= OS_MAX_LOCAL_PATH_LEN ||
strlen(virt_path) >= OS_MAX_PATH_LEN)
{
return OS_ERR_NAME_TOO_LONG;
Expand All @@ -462,7 +462,7 @@ int32 OS_FileSysAddFixedMap(uint32 *filesys_id, const char *phys_path, const cha
++dev_name;
}

if (strlen(dev_name) >= OS_MAX_API_NAME)
if (strlen(dev_name) >= OS_FS_DEV_NAME_LEN)
{
return OS_ERR_NAME_TOO_LONG;
}
Expand Down
8 changes: 5 additions & 3 deletions src/unit-test-coverage/shared/src/coveragetest-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ void Test_OS_FileSysAddFixedMap(void)
OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, "/phys", "/virt"), OS_SUCCESS);
OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, NULL, NULL), OS_INVALID_POINTER);

UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN);
UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 1, 2 + OS_MAX_LOCAL_PATH_LEN);
OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, "/phys", "/virt"), OS_ERR_NAME_TOO_LONG);
UT_ClearForceFail(UT_KEY(OCS_strlen));
UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 2, 2 + OS_MAX_PATH_LEN);
OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, "/phys", "/virt"), OS_ERR_NAME_TOO_LONG);
UT_ResetState(UT_KEY(OCS_strlen));

UT_SetForceFail(UT_KEY(OCS_strrchr), -1);
UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 3, 2 + OS_MAX_API_NAME);
UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 3, 2 + OS_FS_DEV_NAME_LEN);
OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, "/phys", "/virt"), OS_ERR_NAME_TOO_LONG);
UT_ResetState(UT_KEY(OCS_strlen));
UT_ResetState(UT_KEY(OCS_strrchr));
Expand Down