flush buffer in serializer::dump_escaped case UTF8_REJECT
serializer use fixed buffer. Whenever it is nearly full, it is flushed to `output_adapter_t<char> o` But the code forgets to flush when there is a invalid utf8 code point So there will be buffer overflow.
This commit is contained in:
		
							parent
							
								
									dffae1082f
								
							
						
					
					
						commit
						899bd94b43
					
				
					 4 changed files with 89 additions and 0 deletions
				
			
		|  | @ -454,6 +454,16 @@ class serializer | |||
|                                     string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBF'); | ||||
|                                     string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBD'); | ||||
|                                 } | ||||
| 
 | ||||
|                                 // write buffer and reset index; there must be 13 bytes
 | ||||
|                                 // left, as this is the maximal number of bytes to be
 | ||||
|                                 // written ("\uxxxx\uxxxx\0") for one code point
 | ||||
|                                 if (string_buffer.size() - bytes < 13) | ||||
|                                 { | ||||
|                                     o->write_characters(string_buffer.data(), bytes); | ||||
|                                     bytes = 0; | ||||
|                                 } | ||||
| 
 | ||||
|                                 bytes_after_last_accept = bytes; | ||||
|                             } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue