Skip to content

Commit

Permalink
Merge pull request #688 from CDKnightNASA/fix-687-tblhandle_verify
Browse files Browse the repository at this point in the history
Fix #687, validate table handle prior to use
  • Loading branch information
astrogeco authored May 19, 2020
2 parents df31b09 + 84809a7 commit 0fa7baf
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions fsw/cfe-core/src/tbl/cfe_tbl_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,20 +678,14 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle,
int32 Status;
uint32 ThisAppId;
CFE_TBL_LoadBuff_t *WorkingBufferPtr;
CFE_TBL_AccessDescriptor_t *AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle];
CFE_TBL_RegistryRec_t *RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex];
char AppName[OS_MAX_API_NAME]={"UNKNOWN"};
CFE_TBL_AccessDescriptor_t *AccessDescPtr;
CFE_TBL_RegistryRec_t *RegRecPtr;
char AppName[OS_MAX_API_NAME] = {"UNKNOWN"};
bool FirstTime = false;

/* Verify access rights and get a valid Application ID for calling App */
Status = CFE_TBL_ValidateAccess(TblHandle, &ThisAppId);

/* Translate AppID of caller into App Name */
CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME);

/* Initialize return pointer to NULL */
WorkingBufferPtr = NULL;

if (Status != CFE_SUCCESS)
{
CFE_EVS_SendEventWithAppID(CFE_TBL_HANDLE_ACCESS_ERR_EID, CFE_EVS_EventType_ERROR,
Expand All @@ -701,6 +695,15 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle,
return Status;
}

AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle];
RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex];

/* Translate AppID of caller into App Name */
CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME);

/* Initialize return pointer to NULL */
WorkingBufferPtr = NULL;

/* Check to see if this is a dump only table */
if (RegRecPtr->DumpOnly)
{
Expand Down

0 comments on commit 0fa7baf

Please sign in to comment.