- After a bug at TRICS I replaced all occurrences of strcpy, strcat, sprintf
by length limited versions wherever appropriate. SKIPPED: psi/el755driv.c psi/faverage.c psi/frame.c psi/lmd200.c psi/polterwrite.c psi/psi.c psi/sanswave.c psi/sinqhmdriv.c psi/termprot.c
This commit is contained in:
14
motorsec.c
14
motorsec.c
@@ -134,20 +134,20 @@ static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget,
|
||||
|
||||
/* check for fixed */
|
||||
if (fixed >= 0) {
|
||||
sprintf(pBueffel, "Motor %s is Fixed", self->name);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "Motor %s is Fixed", self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
return 0; /* is this an error? */
|
||||
}
|
||||
|
||||
/* check against software boundaries */
|
||||
if (fVal > upperlim) {
|
||||
sprintf(pBueffel, "%f violates upper software limit %f on %s",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%f violates upper software limit %f on %s",
|
||||
fVal, upperlim, self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
if (fVal < lowerlim) {
|
||||
sprintf(pBueffel, "%f violates lower software limit %f on %s",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%f violates lower software limit %f on %s",
|
||||
fVal, lowerlim, self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
@@ -165,13 +165,13 @@ static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget,
|
||||
SecMotorGetPar(self, "hardlowerlim", &hlower);
|
||||
SecMotorGetPar(self, "hardupperlim", &hupper);
|
||||
if (fHard > hupper) {
|
||||
sprintf(pBueffel, "%f violates upper hardware limit %f on %s",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%f violates upper hardware limit %f on %s",
|
||||
fVal, hupper, self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
}
|
||||
if (fHard < hlower) {
|
||||
sprintf(pBueffel, "%f violates lower hardware limit %f on %s",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%f violates lower hardware limit %f on %s",
|
||||
fVal, hlower, self->name);
|
||||
strncpy(pError, pBueffel, iErrLen);
|
||||
return 0;
|
||||
@@ -416,7 +416,7 @@ static hdbCallbackReturn SecMotorCallback(pHdb node, void *userData,
|
||||
*/
|
||||
SecMotorGetPar(self, "accesscode", &fVal);
|
||||
if (!SCMatchRights(pCon, (int) fVal)) {
|
||||
sprintf(pBueffel, "ERROR: You are not authorised to move motor %s",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: You are not authorised to move motor %s",
|
||||
self->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
SCSetInterrupt(pCon, eAbortBatch);
|
||||
@@ -454,7 +454,7 @@ static hdbCallbackReturn SecMotorCallback(pHdb node, void *userData,
|
||||
/* big alarm */
|
||||
ServerWriteGlobal("ERROR: !!! MOTOR ALARM !!! MOTOR ALARM !!!",
|
||||
eError);
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"ERROR: too many position errors counted at motor %s",
|
||||
self->name);
|
||||
ServerWriteGlobal(pBueffel, eError);
|
||||
|
||||
Reference in New Issue
Block a user