File tree Expand file tree Collapse file tree 15 files changed +135
-30
lines changed
Expand file tree Collapse file tree 15 files changed +135
-30
lines changed Original file line number Diff line number Diff line change @@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
213213 /* Were we able to get a free context? */
214214 if ( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
215215 {
216- /* Allocate the stack space. */
217- pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
216+ /* Allocate the stack space if possible. */
217+ if ( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
218+ {
219+ pucStackMemory = NULL ;
220+ }
221+ else
222+ {
223+ pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
224+ }
218225
219226 if ( pucStackMemory != NULL )
220227 {
Original file line number Diff line number Diff line change @@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
213213 /* Were we able to get a free context? */
214214 if ( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
215215 {
216- /* Allocate the stack space. */
217- pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
216+ /* Allocate the stack space if possible. */
217+ if ( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
218+ {
219+ pucStackMemory = NULL ;
220+ }
221+ else
222+ {
223+ pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
224+ }
218225
219226 if ( pucStackMemory != NULL )
220227 {
Original file line number Diff line number Diff line change @@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
213213 /* Were we able to get a free context? */
214214 if ( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
215215 {
216- /* Allocate the stack space. */
217- pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
216+ /* Allocate the stack space if possible. */
217+ if ( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
218+ {
219+ pucStackMemory = NULL ;
220+ }
221+ else
222+ {
223+ pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
224+ }
218225
219226 if ( pucStackMemory != NULL )
220227 {
Original file line number Diff line number Diff line change @@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
213213 /* Were we able to get a free context? */
214214 if ( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
215215 {
216- /* Allocate the stack space. */
217- pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
216+ /* Allocate the stack space if possible. */
217+ if ( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
218+ {
219+ pucStackMemory = NULL ;
220+ }
221+ else
222+ {
223+ pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
224+ }
218225
219226 if ( pucStackMemory != NULL )
220227 {
Original file line number Diff line number Diff line change @@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
213213 /* Were we able to get a free context? */
214214 if ( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
215215 {
216- /* Allocate the stack space. */
217- pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
216+ /* Allocate the stack space if possible. */
217+ if ( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
218+ {
219+ pucStackMemory = NULL ;
220+ }
221+ else
222+ {
223+ pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
224+ }
218225
219226 if ( pucStackMemory != NULL )
220227 {
Original file line number Diff line number Diff line change @@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
213213 /* Were we able to get a free context? */
214214 if ( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
215215 {
216- /* Allocate the stack space. */
217- pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
216+ /* Allocate the stack space if possible. */
217+ if ( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
218+ {
219+ pucStackMemory = NULL ;
220+ }
221+ else
222+ {
223+ pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
224+ }
218225
219226 if ( pucStackMemory != NULL )
220227 {
Original file line number Diff line number Diff line change @@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
213213 /* Were we able to get a free context? */
214214 if ( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
215215 {
216- /* Allocate the stack space. */
217- pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
216+ /* Allocate the stack space if possible. */
217+ if ( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
218+ {
219+ pucStackMemory = NULL ;
220+ }
221+ else
222+ {
223+ pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
224+ }
218225
219226 if ( pucStackMemory != NULL )
220227 {
Original file line number Diff line number Diff line change @@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
213213 /* Were we able to get a free context? */
214214 if ( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
215215 {
216- /* Allocate the stack space. */
217- pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
216+ /* Allocate the stack space if possible. */
217+ if ( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
218+ {
219+ pucStackMemory = NULL ;
220+ }
221+ else
222+ {
223+ pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
224+ }
218225
219226 if ( pucStackMemory != NULL )
220227 {
Original file line number Diff line number Diff line change @@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
213213 /* Were we able to get a free context? */
214214 if ( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
215215 {
216- /* Allocate the stack space. */
217- pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
216+ /* Allocate the stack space if possible. */
217+ if ( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
218+ {
219+ pucStackMemory = NULL ;
220+ }
221+ else
222+ {
223+ pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
224+ }
218225
219226 if ( pucStackMemory != NULL )
220227 {
Original file line number Diff line number Diff line change @@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
213213 /* Were we able to get a free context? */
214214 if ( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
215215 {
216- /* Allocate the stack space. */
217- pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
216+ /* Allocate the stack space if possible. */
217+ if ( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
218+ {
219+ pucStackMemory = NULL ;
220+ }
221+ else
222+ {
223+ pucStackMemory = pvPortMalloc ( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
224+ }
218225
219226 if ( pucStackMemory != NULL )
220227 {
You can’t perform that action at this time.
0 commit comments