Fix def error handling for buffer overflow

This commit is contained in:
Rob Taylor 2023-08-26 15:07:13 +01:00 committed by Jean-Paul Chaput
parent c0dfed21e4
commit bf95753d65
1 changed files with 50 additions and 50 deletions

View File

@ -1213,10 +1213,10 @@ void defiNet::changeNetName(const char* name) {
void defiNet::changeInstance(const char* instance, int index) {
int len;
char errMsg[128];
char errMsg[256];
if ((index < 0) || (index > numPins_)) {
sprintf (errMsg, "ERROR (DEFPARS-6083): The index number %d specified for the NET INSTANCE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6083): The index number %d specified for the NET INSTANCE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPins_);
defiError(0, 6083, errMsg, defData);
}
@ -1231,10 +1231,10 @@ void defiNet::changeInstance(const char* instance, int index) {
void defiNet::changePin(const char* pin, int index) {
int len;
char errMsg[128];
char errMsg[256];
if ((index < 0) || (index > numPins_)) {
sprintf (errMsg, "ERROR (DEFPARS-6084): The index number %d specified for the NET PIN is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6084): The index number %d specified for the NET PIN is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPins_);
defiError(0, 6084, errMsg, defData);
}
@ -2517,9 +2517,9 @@ int defiNet::numPolygons() const {
// 5.6
const char* defiNet::polygonName(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPolys_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPolys_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2528,9 +2528,9 @@ const char* defiNet::polygonName(int index) const {
}
const char* defiNet::polyRouteStatus(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPolys_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPolys_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2539,9 +2539,9 @@ const char* defiNet::polyRouteStatus(int index) const {
}
const char* defiNet::polyRouteStatusShieldName(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPolys_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPolys_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2550,9 +2550,9 @@ const char* defiNet::polyRouteStatusShieldName(int index) const {
}
const char* defiNet::polyShapeType(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPolys_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPolys_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2561,9 +2561,9 @@ const char* defiNet::polyShapeType(int index) const {
}
int defiNet::polyMask(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPolys_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPolys_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2667,9 +2667,9 @@ int defiNet::numRectangles() const {
// 5.6
const char* defiNet::rectName(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numRects_) {
sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numRects_);
defiError(0, 6086, errMsg, defData);
return 0;
@ -2678,9 +2678,9 @@ const char* defiNet::rectName(int index) const {
}
const char* defiNet::rectRouteStatus(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numRects_) {
sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numRects_);
defiError(0, 6086, errMsg, defData);
return 0;
@ -2689,9 +2689,9 @@ const char* defiNet::rectRouteStatus(int index) const {
}
const char* defiNet::rectRouteStatusShieldName(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numRects_) {
sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numRects_);
defiError(0, 6086, errMsg, defData);
return 0;
@ -2700,9 +2700,9 @@ const char* defiNet::rectRouteStatusShieldName(int index) const {
}
const char* defiNet::rectShapeType(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numRects_) {
sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numRects_);
defiError(0, 6086, errMsg, defData);
return 0;
@ -2712,9 +2712,9 @@ const char* defiNet::rectShapeType(int index) const {
// 5.6
int defiNet::xl(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index >= numRects_) {
sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numRects_);
defiError(0, 6086, errMsg, defData);
return 0;
@ -2724,9 +2724,9 @@ int defiNet::xl(int index) const {
// 5.6
int defiNet::yl(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index >= numRects_) {
sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numRects_);
defiError(0, 6086, errMsg, defData);
return 0;
@ -2736,9 +2736,9 @@ int defiNet::yl(int index) const {
// 5.6
int defiNet::xh(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index >= numRects_) {
sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numRects_);
defiError(0, 6086, errMsg, defData);
return 0;
@ -2748,9 +2748,9 @@ int defiNet::xh(int index) const {
// 5.6
int defiNet::yh(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index >= numRects_) {
sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numRects_);
defiError(0, 6086, errMsg, defData);
return 0;
@ -2759,9 +2759,9 @@ int defiNet::yh(int index) const {
}
int defiNet::rectMask(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index >= numRects_) {
sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numRects_);
defiError(0, 6086, errMsg, defData);
return 0;
@ -2857,9 +2857,9 @@ int defiNet::numViaSpecs() const {
}
const char* defiNet::viaName(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPts_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPts_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2868,9 +2868,9 @@ const char* defiNet::viaName(int index) const {
}
const char* defiNet::viaRouteStatus(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPts_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPts_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2879,9 +2879,9 @@ const char* defiNet::viaRouteStatus(int index) const {
}
const char* defiNet::viaRouteStatusShieldName(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPts_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPts_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2890,9 +2890,9 @@ const char* defiNet::viaRouteStatusShieldName(int index) const {
}
const char* defiNet::viaShapeType(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPts_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPts_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2901,9 +2901,9 @@ const char* defiNet::viaShapeType(int index) const {
}
const int defiNet::viaOrient(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPts_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPts_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2912,10 +2912,10 @@ const int defiNet::viaOrient(int index) const {
}
const char* defiNet::viaOrientStr(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPts_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPts_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2924,9 +2924,9 @@ const char* defiNet::viaOrientStr(int index) const {
}
const int defiNet::topMaskNum(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPts_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPts_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2936,9 +2936,9 @@ const int defiNet::topMaskNum(int index) const {
}
const int defiNet::cutMaskNum(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPts_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPts_);
defiError(0, 6085, errMsg, defData);
return 0;
@ -2948,9 +2948,9 @@ const int defiNet::cutMaskNum(int index) const {
}
const int defiNet::bottomMaskNum(int index) const {
char errMsg[128];
char errMsg[256];
if (index < 0 || index > numPts_) {
sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
snprintf (errMsg, 256, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
index, numPts_);
defiError(0, 6085, errMsg, defData);
return 0;