mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	GCC12: Fixes for 16+
Most issues were in stringfields and had to do with comparing a pointer to an constant/interned string with NULL. Since the string was a constant, a pointer to it could never be NULL so the comparison was always "true". gcc now complains about that. There were also a few issues where determining if there was enough space for a memcpy or s(n)printf which were fixed by defining some of the involved variables as "volatile". There were also a few other miscellaneous fixes. ASTERISK-30044 Change-Id: Ia081ca1bcfb329df6487c4660aaf1944309eb570
This commit is contained in:
		
				
					committed by
					
						 Friendly Automation
						Friendly Automation
					
				
			
			
				
	
			
			
			
						parent
						
							4fec26923e
						
					
				
				
					commit
					3c96566655
				
			
							
								
								
									
										15
									
								
								main/pbx.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								main/pbx.c
									
									
									
									
									
								
							| @@ -1652,6 +1652,7 @@ static const char *get_pattern_node(struct pattern_node *node, const char *src, | ||||
| #undef INC_DST_OVERFLOW_CHECK | ||||
| } | ||||
|  | ||||
| #define MAX_EXTENBUF_SIZE 512 | ||||
| static struct match_char *add_exten_to_pattern_tree(struct ast_context *con, struct ast_exten *e1, int findonly) | ||||
| { | ||||
| 	struct match_char *m1 = NULL; | ||||
| @@ -1662,11 +1663,13 @@ static struct match_char *add_exten_to_pattern_tree(struct ast_context *con, str | ||||
| 	int pattern = 0; | ||||
| 	int idx_cur; | ||||
| 	int idx_next; | ||||
| 	char extenbuf[512]; | ||||
| 	char extenbuf[MAX_EXTENBUF_SIZE]; | ||||
| 	volatile size_t required_space = strlen(e1->exten) + 1; | ||||
| 	struct pattern_node pat_node[2]; | ||||
|  | ||||
| 	if (e1->matchcid) { | ||||
| 		if (sizeof(extenbuf) < strlen(e1->exten) + strlen(e1->cidmatch) + 2) { | ||||
| 		required_space += (strlen(e1->cidmatch) + 2 /* '/' + NULL */); | ||||
| 		if (required_space > MAX_EXTENBUF_SIZE) { | ||||
| 			ast_log(LOG_ERROR, | ||||
| 				"The pattern %s/%s is too big to deal with: it will be ignored! Disaster!\n", | ||||
| 				e1->exten, e1->cidmatch); | ||||
| @@ -1674,7 +1677,13 @@ static struct match_char *add_exten_to_pattern_tree(struct ast_context *con, str | ||||
| 		} | ||||
| 		sprintf(extenbuf, "%s/%s", e1->exten, e1->cidmatch);/* Safe.  We just checked. */ | ||||
| 	} else { | ||||
| 		ast_copy_string(extenbuf, e1->exten, sizeof(extenbuf)); | ||||
| 		if (required_space > MAX_EXTENBUF_SIZE) { | ||||
| 			ast_log(LOG_ERROR, | ||||
| 				"The pattern %s/%s is too big to deal with: it will be ignored! Disaster!\n", | ||||
| 				e1->exten, e1->cidmatch); | ||||
| 			return NULL; | ||||
| 		} | ||||
| 		ast_copy_string(extenbuf, e1->exten, required_space); | ||||
| 	} | ||||
|  | ||||
| #ifdef NEED_DEBUG | ||||
|   | ||||
		Reference in New Issue
	
	Block a user