mirror of
				https://github.com/FreeRTOS/FreeRTOS-Kernel.git
				synced 2025-11-04 11:09:01 +01:00 
			
		
		
		
	Refine heap_5 heap protector (#1146)
Add configVALIDATE_HEAP_BLOCK_POINTER on heap_5 heap_5 is used for multiple separated memory spaces. In the previous implementation, it only verifies the highest and lowest addresses. A pointer may not be within heap regions, but is still located between the highest and lowest addressed. Add maco configVALIDATE_HEAP_BLOCK_POINTER to provide customized heap block pointers detection based on the settings of heap regions. Signed-off-by: wangfei_chen <wangfei_chen@realsil.com.cn>
This commit is contained in:
		
							parent
							
								
									d3052f1f50
								
							
						
					
					
						commit
						61440fc664
					
				@ -129,12 +129,19 @@
 | 
				
			|||||||
 * heapVALIDATE_BLOCK_POINTER assert. */
 | 
					 * heapVALIDATE_BLOCK_POINTER assert. */
 | 
				
			||||||
    #define heapPROTECT_BLOCK_POINTER( pxBlock )    ( ( BlockLink_t * ) ( ( ( portPOINTER_SIZE_TYPE ) ( pxBlock ) ) ^ xHeapCanary ) )
 | 
					    #define heapPROTECT_BLOCK_POINTER( pxBlock )    ( ( BlockLink_t * ) ( ( ( portPOINTER_SIZE_TYPE ) ( pxBlock ) ) ^ xHeapCanary ) )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Assert that a heap block pointer is within the heap bounds. */
 | 
					/* Assert that a heap block pointer is within the heap bounds.
 | 
				
			||||||
    #define heapVALIDATE_BLOCK_POINTER( pxBlock )                       \
 | 
					 * Setting configVALIDATE_HEAP_BLOCK_POINTER to 1 enables customized heap block pointers
 | 
				
			||||||
    configASSERT( ( pucHeapHighAddress != NULL ) &&                     \
 | 
					 * protection on heap_5. */
 | 
				
			||||||
                  ( pucHeapLowAddress != NULL ) &&                      \
 | 
					    #ifndef configVALIDATE_HEAP_BLOCK_POINTER
 | 
				
			||||||
                  ( ( uint8_t * ) ( pxBlock ) >= pucHeapLowAddress ) && \
 | 
					        #define heapVALIDATE_BLOCK_POINTER( pxBlock )                           \
 | 
				
			||||||
                  ( ( uint8_t * ) ( pxBlock ) < pucHeapHighAddress ) )
 | 
					            configASSERT( ( pucHeapHighAddress != NULL ) &&                     \
 | 
				
			||||||
 | 
					                          ( pucHeapLowAddress != NULL ) &&                      \
 | 
				
			||||||
 | 
					                          ( ( uint8_t * ) ( pxBlock ) >= pucHeapLowAddress ) && \
 | 
				
			||||||
 | 
					                          ( ( uint8_t * ) ( pxBlock ) < pucHeapHighAddress ) )
 | 
				
			||||||
 | 
					    #else /* ifndef configVALIDATE_HEAP_BLOCK_POINTER */
 | 
				
			||||||
 | 
					        #define heapVALIDATE_BLOCK_POINTER( pxBlock )                           \
 | 
				
			||||||
 | 
					            configVALIDATE_HEAP_BLOCK_POINTER( pxBlock )
 | 
				
			||||||
 | 
					    #endif /* configVALIDATE_HEAP_BLOCK_POINTER */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else /* if ( configENABLE_HEAP_PROTECTOR == 1 ) */
 | 
					#else /* if ( configENABLE_HEAP_PROTECTOR == 1 ) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user