Skip to content

Commit

Permalink
Merge pull request #523 from uyjulian/network_nullpo_check
Browse files Browse the repository at this point in the history
Add null pointer checks on network mailbox code
  • Loading branch information
fjtrujy authored Feb 6, 2024
2 parents 6f160a0 + 46a221b commit baefabc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 8 additions & 3 deletions ee/network/tcpip/src/sys_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static void RetrieveMbxInternal(sys_mbox_t mBox, arch_message **message)
*message=mBox->FirstMessage; //Take first message in mbox

//The next message is next. If there is no next message, NULL is assigned,
NextMessage=(unsigned int)(*message)->next!=0xFFFFFFFF?(*message)->next:NULL;
NextMessage=((*message != NULL) && ((unsigned int)(*message)->next!=0xFFFFFFFF))?(*message)->next:NULL;

//if the mbox only had one message, then update LastMessage as well.
if(mBox->FirstMessage == mBox->LastMessage)
Expand Down Expand Up @@ -275,6 +275,8 @@ static u32_t sys_arch_mbox_fetch_internal(sys_mbox_t pMBox, void** ppvMSG, u32_t
unsigned int TimeElasped;
int result;

pmsg = NULL;
result = -1;
TimeElasped=0;
if(block){
int start;
Expand All @@ -292,8 +294,11 @@ static u32_t sys_arch_mbox_fetch_internal(sys_mbox_t pMBox, void** ppvMSG, u32_t
}

if(result==0){
if(ppvMSG!=NULL) *ppvMSG = pmsg->sys_msg;
free_msg(pmsg);
if (pmsg != NULL)
{
if(ppvMSG!=NULL) *ppvMSG = pmsg->sys_msg;
free_msg(pmsg);
}
}

//Return the number of msec waited.
Expand Down
9 changes: 7 additions & 2 deletions iop/tcpip/tcpip-base/sys_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ static u32_t sys_arch_mbox_fetch_internal(sys_mbox_t pMBox, void** ppvMSG, u32_t
iop_sys_clock_t End;
int result;

pmsg = 0;
result = -1;
if(block){
int iPID;

Expand Down Expand Up @@ -231,8 +233,11 @@ static u32_t sys_arch_mbox_fetch_internal(sys_mbox_t pMBox, void** ppvMSG, u32_t
}

if(result==0){
*ppvMSG = ((arch_message *)pmsg)->sys_msg;
free_msg((arch_message *) pmsg);
if (pmsg != NULL)
{
*ppvMSG = ((arch_message *)pmsg)->sys_msg;
free_msg((arch_message *) pmsg);
}
}

//Return the number of msec waited.
Expand Down

0 comments on commit baefabc

Please sign in to comment.