- replaced sprintf by snprintf after appearance of a buf

This commit is contained in:
zolliker
2011-08-05 07:09:06 +00:00
parent 8162f117bd
commit b0fca0f96f

View File

@ -92,7 +92,7 @@ int TecsWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[]) int argc, char *argv[])
{ {
pEVControl self = NULL; pEVControl self = NULL;
char pBueffel[256], result[1024], *res; char pBueffel[1024], result[1024], *res;
int iRet; int iRet;
pEVDriver pD; pEVDriver pD;
pTecsDriv pMe; pTecsDriv pMe;
@ -170,7 +170,7 @@ int TecsWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
goto Error; goto Error;
fVal = atof(result); fVal = atof(result);
if (argc == 3 && atof(argv[2]) > fVal) { if (argc == 3 && atof(argv[2]) > fVal) {
sprintf(pBueffel, snprintf(pBueffel, sizeof pBueffel,
"WARNING: upper limit reduced to maximal allowed value: %g", "WARNING: upper limit reduced to maximal allowed value: %g",
fVal); fVal);
SCWrite(pCon, pBueffel, eWarning); SCWrite(pCon, pBueffel, eWarning);
@ -185,7 +185,8 @@ int TecsWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
iRet = 1; iRet = 1;
} }
if (iRet) { if (iRet) {
sprintf(pBueffel, "%s.%s = %s\n", self->pName, argv[1], result); snprintf(pBueffel, sizeof pBueffel,
"%s.%s = %s\n", self->pName, argv[1], result);
SCWrite(pCon, pBueffel, eValue); SCWrite(pCon, pBueffel, eValue);
} }
return iRet; return iRet;
@ -220,7 +221,8 @@ int TecsWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
} }
if (iRet < 0) if (iRet < 0)
goto Error; goto Error;
sprintf(pBueffel, "%s.%s = %s\n", self->pName, argv[1], result); snprintf(pBueffel, sizeof pBueffel,
"%s.%s = %s\n", self->pName, argv[1], result);
SCWrite(pCon, pBueffel, eValue); SCWrite(pCon, pBueffel, eValue);
return 1; return 1;
} }