Skip to content

Commit

Permalink
Merge pull request #1487 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
osal Integration candidate: Equuleus-rc1+dev21
  • Loading branch information
dzbaker authored Dec 10, 2024
2 parents a201177 + e76aa01 commit dd4f0e9
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Development Build: equuleus-rc1+dev93
- Adding a strstr() check
- See <https://github.com/nasa/osal/pull/1486>

## Development Build: equuleus-rc1+dev89
- Update misnamed member variable in OS_BSP_GlobalData_t
- See <https://github.com/nasa/osal/pull/1416>
Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/*
* Development Build Macro Definitions
*/
#define OS_BUILD_NUMBER 89
#define OS_BUILD_NUMBER 93
#define OS_BUILD_BASELINE "equuleus-rc1"
#define OS_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */
#define OS_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */
Expand Down
10 changes: 10 additions & 0 deletions src/os/shared/src/osapi-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath)
OS_object_token_t token;
int32 return_code;
const char * name_ptr;
char * result;
OS_filesys_internal_record_t *filesys;
size_t SysMountPointLen;
size_t VirtPathLen;
Expand Down Expand Up @@ -702,6 +703,15 @@ int32 OS_TranslatePath(const char *VirtualPath, char *LocalPath)
return OS_FS_ERR_PATH_INVALID;
}

/*
** Preventing backing out of the virtual mount point
*/
result = strstr(VirtualPath, "..");
if (result)
{
return OS_FS_ERR_PATH_INVALID;
}

/* Get a reference lock, as a filesystem check could take some time. */
return_code = OS_ObjectIdGetBySearch(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, OS_FileSys_FindVirtMountPoint,
(void *)VirtualPath, &token);
Expand Down
5 changes: 5 additions & 0 deletions src/unit-test-coverage/shared/src/coveragetest-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,11 @@ void Test_OS_TranslatePath(void)
actual = OS_TranslatePath("invalid/", LocalBuffer);
UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual);

/* Invalid has '..' */
expected = OS_FS_ERR_PATH_INVALID;
actual = OS_TranslatePath("/cf/../test", LocalBuffer);
UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual);

UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetBySearch), OS_ERR_NAME_NOT_FOUND);
actual = OS_TranslatePath("/cf/test", LocalBuffer);
UtAssert_True(actual == expected, "OS_TranslatePath() (%ld) == OS_FS_ERR_PATH_INVALID", (long)actual);
Expand Down
1 change: 1 addition & 0 deletions src/unit-test-coverage/ut-stubs/inc/OCS_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern int OCS_strncmp(const char *s1, const char *s2, size_t n);
extern char * OCS_strncpy(char *dest, const char *src, size_t n);
extern char * OCS_strchr(const char *s, int c);
extern char * OCS_strrchr(const char *s, int c);
extern char * OCS_strstr(const char *haystack, const char *needle);
extern char * OCS_strcat(char *dest, const char *src);
extern char * OCS_strncat(char *dest, const char *src, size_t n);
extern char * OCS_strerror(int errnum);
Expand Down
1 change: 1 addition & 0 deletions src/unit-test-coverage/ut-stubs/override_inc/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define strncpy OCS_strncpy
#define strchr OCS_strchr
#define strrchr OCS_strrchr
#define strstr OCS_strstr
#define strcat OCS_strcat
#define strncat OCS_strncat
#define strerror OCS_strerror
Expand Down
19 changes: 19 additions & 0 deletions src/unit-test-coverage/ut-stubs/src/libc-string-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,25 @@ char *OCS_strrchr(const char *s, int c)
return (char *)&s[Status - 1];
}

char *OCS_strstr(const char *haystack, const char *needle)
{
int32 Status;

Status = UT_DEFAULT_IMPL(OCS_strstr);

if (Status == 0)
{
/* "nominal" response */
return strstr(haystack, needle);
}
if (Status < 0)
{
return (char *)0;
}

return (char *)&haystack[Status - 1];
}

size_t OCS_strlen(const char *s)
{
int32 Status;
Expand Down

0 comments on commit dd4f0e9

Please sign in to comment.