Gerbview: Check RS274X AD command's template parameters

If user opens a specially crafted gerber file, this check prevents Gerbview from infinitely consuming memory.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13235
This commit is contained in:
Daniil Nikolaev 2022-12-22 21:23:19 +00:00 committed by Seth Hillbrand
parent 9b782fa827
commit 605d177810
1 changed files with 10 additions and 0 deletions

View File

@ -865,6 +865,16 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff,
double param = ReadDouble( aText );
dcode->AppendParam( param );
if( !( isspace( *aText ) || *aText == 'X' || *aText == 'x' || *aText == '*' ) )
{
msg.Printf( wxT( "RS274X: aperture macro %s has invalid template "
"parameters\n" ),
TO_UTF8( am_lookup.name ) );
AddMessageToList( msg );
ok = false;
break;
}
while( isspace( *aText ) )
aText++;