Skip to content

Commit

Permalink
fix nasa#687 - validate table handle prior to use
Browse files Browse the repository at this point in the history
  • Loading branch information
CDKnightNASA committed May 7, 2020
1 parent 8365a0c commit 69cd57b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions fsw/cfe-core/src/tbl/cfe_tbl_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,21 +678,13 @@ 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)
if ((Status = CFE_TBL_ValidateAccess(TblHandle, &ThisAppId)) != CFE_SUCCESS)
{
CFE_EVS_SendEventWithAppID(CFE_TBL_HANDLE_ACCESS_ERR_EID, CFE_EVS_EventType_ERROR,
CFE_TBL_TaskData.TableTaskAppId,
Expand All @@ -701,6 +693,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 69cd57b

Please sign in to comment.