mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 10:47:18 +00:00 
			
		
		
		
	func_base64.c: Ensure we set aside enough room for base64 encoded data.
Reported by SingularTricycle on IRC. Fixes #940
This commit is contained in:
		
				
					committed by
					
						![asterisk-org-access-app[bot]](/avatar/58a64b62d62d5b23df7bc832f016f9db?size=40) asterisk-org-access-app[bot]
						asterisk-org-access-app[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							06444290d0
						
					
				
				
					commit
					b8ffe54e4b
				
			| @@ -85,7 +85,10 @@ static int base64_helper(struct ast_channel *chan, const char *cmd, char *data, | ||||
| 			ast_base64encode(buf, (unsigned char *) data, strlen(data), len); | ||||
| 		} else { | ||||
| 			if (len >= 0) { | ||||
| 				ast_str_make_space(str, len ? len : ast_str_strlen(*str) + strlen(data) * 4 / 3 + 2); | ||||
| 				/* This calculation accounts for padding and the trailing 0 byte. Borrowed | ||||
| 				   from utils.c */ | ||||
| 				size_t bytes_needed_to_encode_data = ((strlen(data) * 4 / 3 + 3) & ~3) + 1; | ||||
| 				ast_str_make_space(str, len ? len : ast_str_strlen(*str) + bytes_needed_to_encode_data); | ||||
| 			} | ||||
| 			ast_base64encode(ast_str_buffer(*str) + ast_str_strlen(*str), (unsigned char *) data, strlen(data), ast_str_size(*str) - ast_str_strlen(*str)); | ||||
| 			ast_str_update(*str); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user