Commit afd89c35 authored by Andrew Zonenberg's avatar Andrew Zonenberg Committed by Dick Hollenbeck

1) EDA_DRAW_FRAME::m_showOriginAxis is never initialized in the constructor

2) LIB_RECTANGLE and related classes sscanf data read from a file using "%s"
without field limits, which can cause problems with malformed/really long
inputs.

3) If some of the optional fields in a lib line are missing, "tmp" can remain
uninitialized.
parent ff79e4d2
......@@ -113,6 +113,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
m_showAxis = false; // true to draw axis.
m_showBorderAndTitleBlock = false; // true to display reference sheet.
m_showGridAxis = false; // true to draw the grid axis
m_showOriginAxis = false; // true to draw the grid origin
m_cursorShape = 0;
m_LastGridSizeId = 0;
m_DrawGrid = true; // hide/Show grid. default = show
......
......@@ -122,10 +122,10 @@ bool LIB_ARC::Save( OUTPUTFORMATTER& aFormatter )
bool LIB_ARC::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
{
int startx, starty, endx, endy, cnt;
char tmp[256];
char tmp[256] = "";
char* line = (char*) aLineReader;
cnt = sscanf( line + 2, "%d %d %d %d %d %d %d %d %s %d %d %d %d",
cnt = sscanf( line + 2, "%d %d %d %d %d %d %d %d %255s %d %d %d %d",
&m_Pos.x, &m_Pos.y, &m_Radius, &m_t1, &m_t2, &m_Unit,
&m_Convert, &m_Width, tmp, &startx, &starty, &endx, &endy );
if( cnt < 8 )
......
......@@ -67,10 +67,10 @@ bool LIB_RECTANGLE::Save( OUTPUTFORMATTER& aFormatter )
bool LIB_RECTANGLE::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
{
int cnt;
char tmp[256];
char tmp[256] = "";
char* line = (char*)aLineReader;
cnt = sscanf( line + 2, "%d %d %d %d %d %d %d %s", &m_Pos.x, &m_Pos.y,
cnt = sscanf( line + 2, "%d %d %d %d %d %d %d %255s", &m_Pos.x, &m_Pos.y,
&m_End.x, &m_End.y, &m_Unit, &m_Convert, &m_Width, tmp );
if( cnt < 7 )
......
......@@ -98,7 +98,7 @@ bool LIB_TEXT::Save( OUTPUTFORMATTER& aFormatter )
bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
{
int cnt, thickness;
int cnt, thickness = 0;
char hjustify = 'C', vjustify = 'C';
char buf[256];
char tmp[256];
......@@ -108,7 +108,7 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
buf[0] = 0;
tmp[0] = 0; // For italic option, Not in old versions
cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d \"%[^\"]\" %s %d %c %c",
cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d \"%[^\"]\" %255s %d %c %c",
&angle, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs,
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
&vjustify );
......@@ -122,7 +122,7 @@ bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
}
else
{
cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d %s %s %d %c %c",
cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d %255s %255s %d %c %c",
&angle, &m_Pos.x, &m_Pos.y, &m_Size.x, &m_Attributs,
&m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
&vjustify );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment