Fix potential buffer overflows in eeschema. Fix Bug #1468604 (Assert triggered in eeschema when trying to edit components)
This commit is contained in:
parent
be01e15f66
commit
bdeac4c116
|
@ -68,7 +68,7 @@ bool LIB_CIRCLE::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
|
|||
char tmp[256];
|
||||
char* line = (char*) aLineReader;
|
||||
|
||||
int cnt = sscanf( line + 2, "%d %d %d %d %d %d %s", &m_Pos.x, &m_Pos.y,
|
||||
int cnt = sscanf( line + 2, "%d %d %d %d %d %d %255s", &m_Pos.x, &m_Pos.y,
|
||||
&m_Radius, &m_Unit, &m_Convert, &m_Width, tmp );
|
||||
|
||||
if( cnt < 6 )
|
||||
|
|
|
@ -160,7 +160,7 @@ bool LIB_FIELD::Load( LINE_READER& aLineReader, wxString& errorMsg )
|
|||
|
||||
memset( textVJustify, 0, sizeof( textVJustify ) );
|
||||
|
||||
cnt = sscanf( line, " %d %d %d %c %c %c %s", &m_Pos.x, &m_Pos.y, &m_Size.y,
|
||||
cnt = sscanf( line, " %d %d %d %c %c %c %255s", &m_Pos.x, &m_Pos.y, &m_Size.y,
|
||||
&textOrient, &textVisible, &textHJustify, textVJustify );
|
||||
|
||||
if( cnt < 5 )
|
||||
|
|
|
@ -730,7 +730,7 @@ bool LIB_PIN::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
|
|||
|
||||
*pinAttrs = 0;
|
||||
|
||||
i = sscanf( line + 2, "%s %s %d %d %d %s %d %d %d %d %s %s", pinName,
|
||||
i = sscanf( line + 2, "%255s %63s %d %d %d %63s %d %d %d %d %63s %63s", pinName,
|
||||
pinNum, &m_position.x, &m_position.y, &m_length, pinOrient, &m_numTextSize,
|
||||
&m_nameTextSize, &m_Unit, &m_Convert, pinType, pinAttrs );
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ again." );
|
|||
break;
|
||||
|
||||
case 'T': // It is a text item.
|
||||
if( sscanf( sline, "%s", name1 ) != 1 )
|
||||
if( sscanf( sline, "%255s", name1 ) != 1 )
|
||||
{
|
||||
msgDiag.Printf( _( "Eeschema file text load error at line %d" ),
|
||||
reader.LineNumber() );
|
||||
|
|
|
@ -293,6 +293,7 @@ public:
|
|||
{
|
||||
if( each_component->GetPartName() != m_requested_name ) continue;
|
||||
each_component->SetPartName( m_new_name );
|
||||
each_component->ClearFlags();
|
||||
aRescuer->LogRescue( each_component, m_requested_name, m_new_name );
|
||||
}
|
||||
return true;
|
||||
|
@ -409,6 +410,7 @@ public:
|
|||
{
|
||||
if( each_component->GetPartName() != m_requested_name ) continue;
|
||||
each_component->SetPartName( m_new_name );
|
||||
each_component->ClearFlags();
|
||||
aRescuer->LogRescue( each_component, m_requested_name, m_new_name );
|
||||
}
|
||||
return true;
|
||||
|
@ -481,6 +483,7 @@ void RESCUER::UndoRescues()
|
|||
BOOST_FOREACH( RESCUE_LOG& each_logitem, m_rescue_log )
|
||||
{
|
||||
each_logitem.component->SetPartName( each_logitem.old_name );
|
||||
each_logitem.component->ClearFlags();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ bool SCH_BUS_ENTRY_BASE::Load( LINE_READER& aLine, wxString& aErrorMsg,
|
|||
while( (*line != ' ' ) && *line )
|
||||
line++;
|
||||
|
||||
if( sscanf( line, "%s %s", Name1, Name2 ) != 2 )
|
||||
if( sscanf( line, "%255s %255s", Name1, Name2 ) != 2 )
|
||||
{
|
||||
aErrorMsg.Printf( wxT( "Eeschema file bus entry load error at line %d" ),
|
||||
aLine.LineNumber() );
|
||||
|
|
|
@ -1148,7 +1148,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
return true;
|
||||
}
|
||||
|
||||
if( sscanf( &line[1], "%s %s", name1, name2 ) != 2 )
|
||||
if( sscanf( &line[1], "%255s %255s", name1, name2 ) != 2 )
|
||||
{
|
||||
aErrorMsg.Printf( wxT( "Eeschema component description error at line %d, aborted" ),
|
||||
aLine.LineNumber() );
|
||||
|
@ -1354,7 +1354,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
memset( char3, 0, sizeof(char3) );
|
||||
int x, y, w, attr;
|
||||
|
||||
if( ( ii = sscanf( ptcar, "%s %d %d %d %X %s %s", char1, &x, &y, &w, &attr,
|
||||
if( ( ii = sscanf( ptcar, "%255s %d %d %d %X %255s %255s", char1, &x, &y, &w, &attr,
|
||||
char2, char3 ) ) < 4 )
|
||||
{
|
||||
aErrorMsg.Printf( wxT( "Component Field error line %d, aborted" ),
|
||||
|
|
|
@ -86,7 +86,7 @@ bool SCH_JUNCTION::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
while( (*line != ' ' ) && *line )
|
||||
line++;
|
||||
|
||||
if( sscanf( line, "%s %d %d", name, &m_pos.x, &m_pos.y ) != 3 )
|
||||
if( sscanf( line, "%255s %d %d", name, &m_pos.x, &m_pos.y ) != 3 )
|
||||
{
|
||||
aErrorMsg.Printf( wxT( "Eeschema file connection load error at line %d, aborted" ),
|
||||
aLine.LineNumber() );
|
||||
|
|
|
@ -174,7 +174,7 @@ bool SCH_LINE::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
while( (*line != ' ' ) && *line )
|
||||
line++;
|
||||
|
||||
if( sscanf( line, "%s %s", Name1, Name2 ) != 2 )
|
||||
if( sscanf( line, "%255s %255s", Name1, Name2 ) != 2 )
|
||||
{
|
||||
aErrorMsg.Printf( wxT( "Eeschema file segment error at line %d, aborted" ),
|
||||
aLine.LineNumber() );
|
||||
|
|
|
@ -101,7 +101,7 @@ bool SCH_NO_CONNECT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
while( (*line != ' ' ) && *line )
|
||||
line++;
|
||||
|
||||
if( sscanf( line, "%s %d %d", name, &m_pos.x, &m_pos.y ) != 3 )
|
||||
if( sscanf( line, "%255s %d %d", name, &m_pos.x, &m_pos.y ) != 3 )
|
||||
{
|
||||
aErrorMsg.Printf( wxT( "Eeschema file No Connect load error at line %d" ),
|
||||
aLine.LineNumber() );
|
||||
|
|
|
@ -428,7 +428,7 @@ bool SCH_TEXT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
sline++;
|
||||
|
||||
// sline points the start of parameters
|
||||
int ii = sscanf( sline, "%s %d %d %d %d %s %s %d", Name1, &m_Pos.x, &m_Pos.y,
|
||||
int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &m_Pos.x, &m_Pos.y,
|
||||
&orient, &size, Name2, Name3, &thickness );
|
||||
|
||||
if( ii < 4 )
|
||||
|
@ -906,7 +906,7 @@ bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
sline++;
|
||||
|
||||
// sline points the start of parameters
|
||||
int ii = sscanf( sline, "%s %d %d %d %d %s %s %d", Name1, &m_Pos.x, &m_Pos.y,
|
||||
int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &m_Pos.x, &m_Pos.y,
|
||||
&orient, &size, Name2, Name3, &thickness );
|
||||
|
||||
if( ii < 4 )
|
||||
|
@ -1067,7 +1067,7 @@ bool SCH_GLOBALLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
sline++;
|
||||
|
||||
// sline points the start of parameters
|
||||
int ii = sscanf( sline, "%s %d %d %d %d %s %s %d", Name1, &m_Pos.x, &m_Pos.y,
|
||||
int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &m_Pos.x, &m_Pos.y,
|
||||
&orient, &size, Name2, Name3, &thickness );
|
||||
|
||||
if( ii < 4 )
|
||||
|
@ -1496,7 +1496,7 @@ bool SCH_HIERLABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
sline++;
|
||||
|
||||
// sline points the start of parameters
|
||||
int ii = sscanf( sline, "%s %d %d %d %d %s %s %d", Name1, &m_Pos.x, &m_Pos.y,
|
||||
int ii = sscanf( sline, "%255s %d %d %d %d %255s %255s %d", Name1, &m_Pos.x, &m_Pos.y,
|
||||
&orient, &size, Name2, Name3, &thickness );
|
||||
|
||||
if( ii < 4 )
|
||||
|
|
Loading…
Reference in New Issue