- 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:
62
selector.c
62
selector.c
@@ -210,7 +210,7 @@ int MonoInit(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
argtolower(argc, argv);
|
||||
pList = SplitArguments(argc, argv);
|
||||
if (!pList) {
|
||||
sprintf(pBueffel, "ERROR: parsing arguments in %s", argv[0]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: parsing arguments in %s", argv[0]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ int MonoInit(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
/* advance and search name */
|
||||
pCurrent = pList->pNext;
|
||||
if (!pCurrent) {
|
||||
sprintf(pBueffel, "ERRROR: Insufficient number of arguments to %s",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERRROR: Insufficient number of arguments to %s",
|
||||
argv[0]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
goto end;
|
||||
@@ -228,7 +228,7 @@ int MonoInit(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
/* advance and find Type string */
|
||||
pCurrent = pCurrent->pNext;
|
||||
if (!pCurrent) {
|
||||
sprintf(pBueffel, "ERRROR: Insufficient number of arguments to %s",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERRROR: Insufficient number of arguments to %s",
|
||||
argv[0]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
goto end;
|
||||
@@ -238,14 +238,14 @@ int MonoInit(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
/* advance and find Theta motor */
|
||||
pCurrent = pCurrent->pNext;
|
||||
if (!pCurrent) {
|
||||
sprintf(pBueffel, "ERRROR: Insufficient number of arguments to %s",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERRROR: Insufficient number of arguments to %s",
|
||||
argv[0]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
goto end;
|
||||
}
|
||||
pTheta = FindMotor(pSics, pCurrent->text);
|
||||
if (!pTheta) {
|
||||
sprintf(pBueffel, "ERROR: Cannot find motor %s for driving Theta",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: Cannot find motor %s for driving Theta",
|
||||
pCurrent->text);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
goto end;
|
||||
@@ -254,14 +254,14 @@ int MonoInit(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
/* advance and find Two Theta motor */
|
||||
pCurrent = pCurrent->pNext;
|
||||
if (!pCurrent) {
|
||||
sprintf(pBueffel, "ERRROR: Insufficient number of arguments to %s",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERRROR: Insufficient number of arguments to %s",
|
||||
argv[0]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
goto end;
|
||||
}
|
||||
pTwoTheta = FindMotor(pSics, pCurrent->text);
|
||||
if (!pTwoTheta) {
|
||||
sprintf(pBueffel, "ERROR: Cannot find motor %s for driving Two Theta",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: Cannot find motor %s for driving Two Theta",
|
||||
pCurrent->text);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
goto end;
|
||||
@@ -273,7 +273,7 @@ int MonoInit(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
if (pCurrent) {
|
||||
pBend1 = FindMotor(pSics, pCurrent->text);
|
||||
if (!pBend1) {
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"ERROR: Cannot find motor %s for driving vertical bender",
|
||||
pCurrent->text);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
@@ -288,7 +288,7 @@ int MonoInit(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
if (pCurrent) {
|
||||
pBend2 = FindMotor(pSics, pCurrent->text);
|
||||
if (!pBend2) {
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"ERROR: Cannot find motor %s for driving horizontal bender",
|
||||
pCurrent->text);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
@@ -310,7 +310,7 @@ end:
|
||||
AddCommand(pSics, pName, MonoAction, DeleteSelector,
|
||||
(void *) pRes);
|
||||
if (!iRet) {
|
||||
sprintf(pBueffel, "ERROR: duplicate command %s not created",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: duplicate command %s not created",
|
||||
argv[2]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
DeleteTokenList(pList);
|
||||
@@ -336,28 +336,28 @@ static void MonoList(pSicsSelector self, SConnection * pCon)
|
||||
|
||||
/* print known parameters */
|
||||
iLen = ObParLength(self->pParams);
|
||||
sprintf(pBueffel, "Parameter Listing for %s\n", self->name);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "Parameter Listing for %s\n", self->name);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
for (i = 0; i < iLen; i++) {
|
||||
sprintf(pBueffel, "%s.%s = %f\n", self->name,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.%s = %f\n", self->name,
|
||||
self->pParams[i].name, self->pParams[i].fVal);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
}
|
||||
|
||||
/* print motornames as well */
|
||||
sprintf(pBueffel, "%s.ThetaMotor = %s\n", self->name,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.ThetaMotor = %s\n", self->name,
|
||||
self->pTheta->name);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
sprintf(pBueffel, "%s.TwoThetaMotor = %s\n", self->name,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.TwoThetaMotor = %s\n", self->name,
|
||||
self->pTwoTheta->name);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
if (self->pBend1) {
|
||||
sprintf(pBueffel, "%s.VerticalBenderMotor = %s\n", self->name,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.VerticalBenderMotor = %s\n", self->name,
|
||||
self->pBend1->name);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
}
|
||||
if (self->pBend2) {
|
||||
sprintf(pBueffel, "%s.HorizontalBenderMotor = %s\n", self->name,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.HorizontalBenderMotor = %s\n", self->name,
|
||||
self->pBend2->name);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
}
|
||||
@@ -392,7 +392,7 @@ int MonoAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
argtolower(argc, argv);
|
||||
pList = SplitArguments(argc, argv);
|
||||
if (!pList) {
|
||||
sprintf(pBueffel, "ERROR: parsing arguments in %s", argv[0]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: parsing arguments in %s", argv[0]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@@ -401,7 +401,7 @@ int MonoAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
/* now we can have "list" or a parametername */
|
||||
/* check for list first */
|
||||
if (!pCurrent) {
|
||||
sprintf(pBueffel, "ERROR: Insufficient number of arguments to %s",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: Insufficient number of arguments to %s",
|
||||
argv[0]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
goto end;
|
||||
@@ -426,7 +426,7 @@ int MonoAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
} else if (pCurrent->Type == eInt) {
|
||||
fVal = (float) pCurrent->iVal;
|
||||
} else {
|
||||
sprintf(pBueffel, "ERROR: Illegal parameter %s given to %s",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: Illegal parameter %s given to %s",
|
||||
pCurrent->text, argv[0]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
goto end;
|
||||
@@ -437,12 +437,12 @@ int MonoAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
|
||||
pPar = ObParFind(pSelf->pParams, pName);
|
||||
if (!pPar) {
|
||||
sprintf(pBueffel, "ERROR: Parameter %s not found in %s", pName,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: Parameter %s not found in %s", pName,
|
||||
argv[0]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
goto end;
|
||||
} else {
|
||||
sprintf(pBueffel, "%s.%s = %f", argv[0], pName, pPar->fVal);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.%s = %f", argv[0], pName, pPar->fVal);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
iRet = 1;
|
||||
DeleteTokenList(pList);
|
||||
@@ -514,7 +514,7 @@ int MonoLimits(pSicsSelector self, float fWaveLength,
|
||||
/* get Position */
|
||||
sNeu = CalculatePosition(self, fWaveLength);
|
||||
if (sNeu.fTheta > 900.) { /* invalid wavelength or energy */
|
||||
sprintf(pBueffel, "ERROR: Invalid wavelength or energy to high: %f",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: Invalid wavelength or energy to high: %f",
|
||||
fWaveLength);
|
||||
strncpy(error, pBueffel, iErrLen - 1);
|
||||
return 0;
|
||||
@@ -596,7 +596,7 @@ int MonoRun(pSicsSelector self, SConnection * pCon, float fWaveLength)
|
||||
|
||||
/* Check authorisation */
|
||||
if (!SCMatchRights(pCon, (int) ObVal(self->pParams, RIGHTS))) {
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"ERROR: You are not authorised to move the monochromator %s",
|
||||
self->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
@@ -606,7 +606,7 @@ int MonoRun(pSicsSelector self, SConnection * pCon, float fWaveLength)
|
||||
/* get Position */
|
||||
sNeu = CalculatePosition(self, fWaveLength);
|
||||
if (sNeu.fTheta > 900.) { /* invalid wavelength or energy */
|
||||
sprintf(pBueffel, "ERROR: Invalid wavelength or energy to high: %f",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: Invalid wavelength or energy to high: %f",
|
||||
fWaveLength);
|
||||
return 0;
|
||||
}
|
||||
@@ -711,7 +711,7 @@ float GetMonoPosition(pSicsSelector self, SConnection * pCon)
|
||||
/* get the two positions */
|
||||
iRet = MotorGetSoftPosition(self->pTheta, pCon, &fTheta);
|
||||
if (!iRet) {
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"ERROR: cannot read Theta motor for monochromator %s\n",
|
||||
self->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
@@ -719,7 +719,7 @@ float GetMonoPosition(pSicsSelector self, SConnection * pCon)
|
||||
}
|
||||
iRet = MotorGetSoftPosition(self->pTwoTheta, pCon, &fTwoTheta);
|
||||
if (!iRet) {
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"ERROR: cannot read TwoTheta motor for monochromator %s\n",
|
||||
self->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
@@ -731,7 +731,7 @@ float GetMonoPosition(pSicsSelector self, SConnection * pCon)
|
||||
if (fVal < 0.)
|
||||
fVal = -fVal;
|
||||
if (fVal > 0.01) {
|
||||
sprintf(pBueffel, "WARNING: monochromator %s out of sync by %f\n",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "WARNING: monochromator %s out of sync by %f\n",
|
||||
self->name, fVal);
|
||||
SCWrite(pCon, pBueffel, eWarning);
|
||||
}
|
||||
@@ -753,7 +753,7 @@ int GetMonoPositions(pSicsSelector self, SConnection * pCon,
|
||||
|
||||
iRet = MotorGetSoftPosition(self->pTheta, pCon, fTh);
|
||||
if (!iRet) {
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"ERROR: cannot read Theta motor for monochromator %s\n",
|
||||
self->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
@@ -761,7 +761,7 @@ int GetMonoPositions(pSicsSelector self, SConnection * pCon,
|
||||
}
|
||||
iRet = MotorGetSoftPosition(self->pTwoTheta, pCon, f2TH);
|
||||
if (!iRet) {
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"ERROR: cannot read TwoTheta motor for monochromator %s\n",
|
||||
self->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
@@ -771,7 +771,7 @@ int GetMonoPositions(pSicsSelector self, SConnection * pCon,
|
||||
if (self->pBend1) {
|
||||
iRet = MotorGetSoftPosition(self->pBend1, pCon, fB1);
|
||||
if (!iRet) {
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"ERROR: cannot read vertical bender motor for monochromator %s\n",
|
||||
self->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
@@ -781,7 +781,7 @@ int GetMonoPositions(pSicsSelector self, SConnection * pCon,
|
||||
if (self->pBend2) {
|
||||
iRet = MotorGetSoftPosition(self->pBend2, pCon, fB2);
|
||||
if (!iRet) {
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"ERROR: cannot read horizontal bender motor for monochromator %s\n",
|
||||
self->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
|
||||
Reference in New Issue
Block a user