From 84809a77e9faa06140df7d45255996c81a2aed95 Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Thu, 7 May 2020 14:36:02 -0700 Subject: [PATCH] fix #687 - validate table handle prior to use --- fsw/cfe-core/src/tbl/cfe_tbl_api.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_api.c b/fsw/cfe-core/src/tbl/cfe_tbl_api.c index 29709871e..299129766 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_api.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_api.c @@ -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, @@ -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) {