- 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:
koennecke
2009-12-04 12:58:31 +00:00
parent 297f9f2e02
commit 8cc5474334
80 changed files with 899 additions and 881 deletions

View File

@@ -58,20 +58,20 @@ static int VarSave(void *pData, char *name, FILE * fd)
if (pVar->iLock || pVar->iAccessCode == usInternal) {
return 1;
}
sprintf(pBueffel, "# Variable %s\n", name);
snprintf(pBueffel,sizeof(pBueffel)-1, "# Variable %s\n", name);
switch (pVar->eType) {
case veText:
sprintf(pBueffel, "%s %s\n", name, pVar->text);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s %s\n", name, pVar->text);
break;
case veInt:
sprintf(pBueffel, "%s %d\n", name, pVar->iVal);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s %d\n", name, pVar->iVal);
break;
case veFloat:
sprintf(pBueffel, "%s %f\n", name, pVar->fVal);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s %f\n", name, pVar->fVal);
break;
}
fputs(pBueffel, fd);
sprintf(pBueffel, "%s setAccess %d\n", name, pVar->iAccessCode);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s setAccess %d\n", name, pVar->iAccessCode);
fputs(pBueffel, fd);
return 1;
}
@@ -150,7 +150,7 @@ int VarFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
/* check if enough commands */
argtolower(argc, argv);
if (argc < 4) {
sprintf(pBueffel,
snprintf(pBueffel,sizeof(pBueffel)-1,
"Insufficient no of args to %s, Usage: %s name type accescode",
argv[0], argv[0]);
SCWrite(pCon, pBueffel, eError);
@@ -177,7 +177,7 @@ int VarFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
eType = veFloat;
break;
default:
sprintf(pBueffel, "Var %s Type --> %s <-- not recognized",
snprintf(pBueffel,sizeof(pBueffel)-1, "Var %s Type --> %s <-- not recognized",
argv[1], argv[2]);
SCWrite(pCon, pBueffel, eError);
return 0;
@@ -186,7 +186,7 @@ int VarFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
/* argv[3] must be the access code, check that now */
i = decodeSICSPriv(argv[3]);
if (i < 0) {
sprintf(pBueffel, " %s access code %s not recognized",
snprintf(pBueffel,sizeof(pBueffel)-1, " %s access code %s not recognized",
argv[1], argv[3]);
SCWrite(pCon, pBueffel, eError);
return 0;
@@ -195,13 +195,13 @@ int VarFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
/* now we can actually install the variable */
pRes = VarCreate(i, eType, argv[1]);
if (!pRes) {
sprintf(pBueffel, "Memory Error creating variable %s", argv[1]);
snprintf(pBueffel,sizeof(pBueffel)-1, "Memory Error creating variable %s", argv[1]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
iRet = AddCommand(pSics, argv[1], VarWrapper, (KillFunc) VarKill, pRes);
if (!iRet) {
sprintf(pBueffel, "ERROR: duplicate command %s not created", argv[1]);
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: duplicate command %s not created", argv[1]);
SCWrite(pCon, pBueffel, eError);
VarKill(pRes);
return 0;
@@ -354,19 +354,19 @@ static int VarInterestCallback(int iEvent, void *pEvent, void *pUser)
switch (pVar->eType) {
case veInt:
VarGetInt(pVar, &iVal);
sprintf(pBueffel, "%s = %d", pVar->name, iVal);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s = %d", pVar->name, iVal);
SCWrite(pCon, pBueffel, eValue);
status = 1;
break;
case veFloat:
VarGetFloat(pVar, &fVal);
sprintf(pBueffel, "%s = %f", pVar->name, fVal);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s = %f", pVar->name, fVal);
SCWrite(pCon, pBueffel, eValue);
status = 1;
break;
case veText:
VarGetText(pVar, &pText);
sprintf(pBueffel, "%s = %s", pVar->name, pText);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s = %s", pVar->name, pText);
SCWrite(pCon, pBueffel, eValue);
if (pText) {
free(pText);
@@ -447,19 +447,19 @@ int VarWrapper(SConnection * pCon, SicsInterp * pInterp, void *pData,
switch (eTyp) {
case veInt:
VarGetInt(pVar, &iVal);
sprintf(pBueffel, "%s = %d", argv[0], iVal);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s = %d", argv[0], iVal);
SCWrite(pCon, pBueffel, eValue);
DeleteTokenList(pList);
return 1;
case veFloat:
VarGetFloat(pVar, &fVal);
sprintf(pBueffel, "%s = %f", argv[0], fVal);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s = %f", argv[0], fVal);
SCWrite(pCon, pBueffel, eValue);
DeleteTokenList(pList);
return 1;
case veText:
VarGetText(pVar, &pText);
sprintf(pBueffel, "%s = %s", argv[0], pText);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s = %s", argv[0], pText);
SCWrite(pCon, pBueffel, eValue);
if (pText) {
free(pText);
@@ -554,7 +554,7 @@ int VarWrapper(SConnection * pCon, SicsInterp * pInterp, void *pData,
if (pCurrent) {
/* is it locked ? */
if (pVar->iLock) {
sprintf(pBueffel, "ERROR: variable %s is configured locked!",
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: variable %s is configured locked!",
argv[0]);
SCWrite(pCon, pBueffel, eError);
DeleteTokenList(pList);