Skip to content

Commit

Permalink
Merge pull request #464 from jphickey/fix-455-devname-length
Browse files Browse the repository at this point in the history
Fix #455, correct length of device_name in filesys
  • Loading branch information
astrogeco authored May 26, 2020
2 parents 9af5078 + 72af6d5 commit d6b167b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
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

0 comments on commit d6b167b

Please sign in to comment.