- 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:
28
counter.c
28
counter.c
@ -268,23 +268,19 @@ static int CheckCountStatus(void *pData, SConnection * pCon)
|
||||
static int SaveCounterStatus(void *pData, char *name, FILE * fd)
|
||||
{
|
||||
pCounter self = NULL;
|
||||
char pBueffel[512];
|
||||
|
||||
assert(pData);
|
||||
assert(fd);
|
||||
|
||||
self = (pCounter) pData;
|
||||
|
||||
sprintf(pBueffel, "# Counter %s\n", name);
|
||||
fputs(pBueffel, fd);
|
||||
sprintf(pBueffel, "%s SetPreset %f\n", name, self->pDriv->fPreset);
|
||||
fputs(pBueffel, fd);
|
||||
fprintf(fd, "# Counter %s\n", name);
|
||||
fprintf(fd, "%s SetPreset %f\n", name, self->pDriv->fPreset);
|
||||
if (self->pDriv->eMode == eTimer) {
|
||||
sprintf(pBueffel, "%s SetMode Timer\n", name);
|
||||
fprintf(fd, "%s SetMode Timer\n", name);
|
||||
} else {
|
||||
sprintf(pBueffel, "%s SetMode Monitor\n", name);
|
||||
fprintf(fd, "%s SetMode Monitor\n", name);
|
||||
}
|
||||
fputs(pBueffel, fd);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -475,7 +471,7 @@ int MakeCounter(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
|
||||
if (!pDriv) {
|
||||
sprintf(pBueffel, "ERROR: cannot create requested driver %s", argv[2]);
|
||||
snprintf(pBueffel,255, "ERROR: cannot create requested driver %s", argv[2]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -483,7 +479,7 @@ int MakeCounter(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
/* create Counter and command */
|
||||
pNew = CreateCounter(argv[1], pDriv);
|
||||
if (!pNew) {
|
||||
sprintf(pBueffel, "ERROR: cannot create counter %s", argv[1]);
|
||||
snprintf(pBueffel, 255,"ERROR: cannot create counter %s", argv[1]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -491,7 +487,7 @@ int MakeCounter(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
AddCommand(pSics, argv[1], CountAction, DeleteCounter,
|
||||
(void *) pNew);
|
||||
if (!iRet) {
|
||||
sprintf(pBueffel, "ERROR: duplicate command %s not created", argv[1]);
|
||||
snprintf(pBueffel,255, "ERROR: duplicate command %s not created", argv[1]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -693,7 +689,7 @@ static int CounterInterest(int iEvent, void *pEvent, void *pUser)
|
||||
pMon = (pMonEvent) pEvent;
|
||||
assert(pCon);
|
||||
assert(pMon);
|
||||
sprintf(pBueffel, "%s.CountStatus = %f %d", pMon->pName, pMon->fPreset,
|
||||
snprintf(pBueffel,511, "%s.CountStatus = %f %d", pMon->pName, pMon->fPreset,
|
||||
(int) nintf(pMon->fCurrent));
|
||||
/**
|
||||
* prevent this to be written to log files
|
||||
@ -814,7 +810,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
EvaluateFuPa((pFuncTemplate) & ActionTemplate, 23, argc - 1, argx,
|
||||
&PaRes);
|
||||
if (iRet < 0) {
|
||||
sprintf(pBueffel, "%s", PaRes.pError);
|
||||
snprintf(pBueffel, 255,"%s", PaRes.pError);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -872,7 +868,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
} else {
|
||||
sprintf(pBueffel, "ERROR: %s not recognized as valid counter mode",
|
||||
snprintf(pBueffel,255, "ERROR: %s not recognized as valid counter mode",
|
||||
PaRes.Arg[0].text);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
@ -1014,7 +1010,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
} else {
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,255,
|
||||
"ERROR: %s not recognized as valid counter mode",
|
||||
PaRes.Arg[0].text);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
@ -1101,7 +1097,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
iRet = self->pDriv->Get(self->pDriv, PaRes.Arg[0].text,
|
||||
PaRes.Arg[1].iVal, &fVal);
|
||||
if (iRet == 1) {
|
||||
sprintf(pBueffel, "%s.%s %d = %f", argv[0], PaRes.Arg[0].text,
|
||||
snprintf(pBueffel,255, "%s.%s %d = %f", argv[0], PaRes.Arg[0].text,
|
||||
PaRes.Arg[1].iVal, fVal);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user