- After a bug at TRICS I replaced all occurrences of strcpy, strcat, sprintf

by length limited versions wherever appropriate.
This commit is contained in:
koennecke
2009-12-04 12:58:45 +00:00
parent 09826fb097
commit 4127cbb166
9 changed files with 42 additions and 43 deletions

24
psi.c
View File

@ -225,7 +225,7 @@ static pMotor CreatePsiMotor(SConnection * pCon, int argc, char *argv[])
/* create the motor */
pNew = MotorInit("PIPIEZO", argv[0], pDriver);
if (!pNew) {
sprintf(pBueffel, "Failure to create motor %s", argv[0]);
snprintf(pBueffel,131, "Failure to create motor %s", argv[0]);
SCWrite(pCon, pBueffel, eError);
return NULL;
}
@ -237,7 +237,7 @@ static pMotor CreatePsiMotor(SConnection * pCon, int argc, char *argv[])
/* create the motor */
pNew = MotorInit("EL734", argv[0], pDriver);
if (!pNew) {
sprintf(pBueffel, "Failure to create motor %s", argv[1]);
snprintf(pBueffel,131, "Failure to create motor %s", argv[1]);
SCWrite(pCon, pBueffel, eError);
return NULL;
}
@ -249,7 +249,7 @@ static pMotor CreatePsiMotor(SConnection * pCon, int argc, char *argv[])
/* create the motor */
pNew = MotorInit("EL734HP", argv[0], pDriver);
if (!pNew) {
sprintf(pBueffel, "Failure to create motor %s", argv[1]);
snprintf(pBueffel,131, "Failure to create motor %s", argv[1]);
SCWrite(pCon, pBueffel, eError);
return NULL;
}
@ -261,7 +261,7 @@ static pMotor CreatePsiMotor(SConnection * pCon, int argc, char *argv[])
/* create the motor */
pNew = MotorInit("EL734HPT", argv[0], pDriver);
if (!pNew) {
sprintf(pBueffel, "Failure to create motor %s", argv[1]);
snprintf(pBueffel,131, "Failure to create motor %s", argv[1]);
SCWrite(pCon, pBueffel, eError);
return NULL;
}
@ -273,7 +273,7 @@ static pMotor CreatePsiMotor(SConnection * pCon, int argc, char *argv[])
/* create the motor */
pNew = MotorInit("EL734DC", argv[0], pDriver);
if (!pNew) {
sprintf(pBueffel, "Failure to create motor %s", argv[1]);
snprintf(pBueffel,131, "Failure to create motor %s", argv[1]);
SCWrite(pCon, pBueffel, eError);
return NULL;
}
@ -285,7 +285,7 @@ static pMotor CreatePsiMotor(SConnection * pCon, int argc, char *argv[])
/* create the motor */
pNew = MotorInit("ECB", argv[0], pDriver);
if (!pNew) {
sprintf(pBueffel, "Failure to create motor %s", argv[0]);
snprintf(pBueffel,131, "Failure to create motor %s", argv[0]);
SCWrite(pCon, pBueffel, eError);
return NULL;
}
@ -389,14 +389,14 @@ static pCodri CreatePsiController(SConnection * pCon, int argc,
}
iRet = Tcl_GetInt(pTcl, argv[2], &iPort);
if (iRet != TCL_OK) {
sprintf(pBueffel, "ERROR: expected integer as port number, got %s",
snprintf(pBueffel,511, "ERROR: expected integer as port number, got %s",
argv[2]);
SCWrite(pCon, pBueffel, eError);
return NULL;
}
iRet = Tcl_GetInt(pTcl, argv[3], &iChannel);
if (iRet != TCL_OK) {
sprintf(pBueffel,
snprintf(pBueffel,511,
"ERROR: expected integer as channel number, got %s",
argv[3]);
SCWrite(pCon, pBueffel, eError);
@ -405,7 +405,7 @@ static pCodri CreatePsiController(SConnection * pCon, int argc,
if (argc > 4) {
iRet = Tcl_GetInt(pTcl, argv[4], &iSingle);
if (iRet != TCL_OK) {
sprintf(pBueffel,
snprintf(pBueffel,511,
"ERROR: expected integer as single flag, got %s", argv[4]);
SCWrite(pCon, pBueffel, eError);
return NULL;
@ -429,7 +429,7 @@ static pCodri CreatePsiController(SConnection * pCon, int argc,
}
iRet = Tcl_GetInt(pTcl, argv[2], &iPort);
if (iRet != TCL_OK) {
sprintf(pBueffel, "ERROR: expected integer as port number, got %s",
snprintf(pBueffel, 511, "ERROR: expected integer as port number, got %s",
argv[2]);
SCWrite(pCon, pBueffel, eError);
return NULL;
@ -576,7 +576,7 @@ static pEVControl InstallPsiEnvironmentController(SicsInterp * pSics,
pNew = CreateEVController(pDriv, argv[2], &status);
}
} else {
sprintf(pBueffel, "ERROR: %s not recognized as a valid driver type",
snprintf(pBueffel,511, "ERROR: %s not recognized as a valid driver type",
argv[3]);
SCWrite(pCon, pBueffel, eError);
return NULL;
@ -591,7 +591,7 @@ static pEVControl InstallPsiEnvironmentController(SicsInterp * pSics,
if (status != 1) {
SCWrite(pCon, "ERROR: failed to initialize device", eError);
pDriv->GetError(pDriv, &status, pError, 131);
sprintf(pBueffel, "HW reported: %s", pError);
snprintf(pBueffel, 511,"HW reported: %s", pError);
SCWrite(pCon, pBueffel, eError);
}
if (pNew == NULL) {