Avoid crash on unexpected "saved dimensions" loading Labels

This commit is contained in:
Bill Kendrick 2022-04-06 01:32:21 -07:00
parent 7db784ce88
commit fb596fb887
2 changed files with 15 additions and 3 deletions

View file

@ -7,7 +7,7 @@ Various contributors (see below, and AUTHORS.txt)
http://www.tuxpaint.org/ http://www.tuxpaint.org/
2022.April.2 (0.9.28) 2022.April.6 (0.9.28)
* Improvements to "Paint" and "Lines" tools: * Improvements to "Paint" and "Lines" tools:
------------------------------------------ ------------------------------------------
* Brush spacing may now be altered within Tux Paint. * Brush spacing may now be altered within Tux Paint.
@ -197,7 +197,8 @@ http://www.tuxpaint.org/
* Avoid crashes when coming across unexpected Label data stored within * Avoid crashes when coming across unexpected Label data stored within
a saved PNG image. a saved PNG image.
(h/t Donny Sianipar for the report & sample image) (h/t Donny Sianipar for the report & sample image,
and Shin-Ichi TOYAMA for additional samples)
Bill Kendrick <bill@newbreedsoftware.com> Bill Kendrick <bill@newbreedsoftware.com>
* Ports & Building: * Ports & Building:

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
June 14, 2002 - April 2, 2022 June 14, 2002 - April 6, 2022
*/ */
#include "platform.h" #include "platform.h"
@ -24403,6 +24403,17 @@ static void load_info_about_label_surface(FILE * lfi)
#ifdef DEBUG #ifdef DEBUG
printf("Original label size %dx%d\n", new_node->save_width, new_node->save_height); printf("Original label size %dx%d\n", new_node->save_width, new_node->save_height);
#endif #endif
if (new_node->save_width > 8192 || new_node->save_height > 8192)
{
fprintf(stderr, "Unexpected! Save dimensions are (%u x %u!)\n", new_node->save_width, new_node->save_height);
free(new_node);
free(wtmpstr);
#ifdef WIN32
free(tmpstr);
#endif
fclose(lfi);
return;
}
/* Read the label's font */ /* Read the label's font */
tmp_fscanf_return = fscanf(lfi, "%d\n", &new_node->save_cur_font); tmp_fscanf_return = fscanf(lfi, "%d\n", &new_node->save_cur_font);