mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 07:57:27 +03:00 
			
		
		
		
	Changed maximum comment length to 65531
This commit is contained in:
		
							parent
							
								
									598216fb46
								
							
						
					
					
						commit
						2f66d2d6a1
					
				|  | @ -376,14 +376,18 @@ def test_save_comment(): | |||
|     for comment in ("Created by Pillow", b"Created by Pillow"): | ||||
|         out = BytesIO() | ||||
|         test_card.save(out, "JPEG2000", comment=comment) | ||||
|         out.seek(0) | ||||
| 
 | ||||
|         with Image.open(out) as im: | ||||
|             assert im.info["comment"] == b"Created by Pillow" | ||||
| 
 | ||||
|     too_long_comment = " " * 65531 | ||||
|     out = BytesIO() | ||||
|     long_comment = b" " * 65531 | ||||
|     test_card.save(out, "JPEG2000", comment=long_comment) | ||||
|     with Image.open(out) as im: | ||||
|         assert im.info["comment"] == long_comment | ||||
| 
 | ||||
|     with pytest.raises(ValueError): | ||||
|         test_card.save(out, "JPEG2000", comment=too_long_comment) | ||||
|         test_card.save(out, "JPEG2000", comment=long_comment + b" ") | ||||
| 
 | ||||
| 
 | ||||
| @pytest.mark.parametrize( | ||||
|  |  | |||
|  | @ -1214,7 +1214,7 @@ PyImaging_Jpeg2KEncoderNew(PyObject *self, PyObject *args) { | |||
|     char mct = 0; | ||||
|     int sgnd = 0; | ||||
|     Py_ssize_t fd = -1; | ||||
|     char *comment = NULL; | ||||
|     char *comment; | ||||
|     Py_ssize_t comment_size; | ||||
|     int plt = 0; | ||||
| 
 | ||||
|  | @ -1323,7 +1323,7 @@ PyImaging_Jpeg2KEncoderNew(PyObject *self, PyObject *args) { | |||
| 
 | ||||
|     if (comment && comment_size > 0) { | ||||
|         /* Size is stored as as an uint16, subtract 4 bytes for the header */ | ||||
|         if (comment_size >= 65531) { | ||||
|         if (comment_size >= 65532) { | ||||
|             PyErr_SetString( | ||||
|                 PyExc_ValueError, | ||||
|                 "JPEG 2000 comment is too long"); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user