- 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

52
lomax.c
View File

@ -290,18 +290,18 @@ static int checkHM(pHistMem * pHM, SicsInterp * pSics, SConnection * pCon,
pCom = FindCommand(pSics, name);
if (!pCom) {
sprintf(pBueffel, "ERROR: histogram memory %s not found", name);
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: histogram memory %s not found", name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
if (!pCom->pData) {
sprintf(pBueffel, "ERROR: histogram memory %s not found", name);
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: histogram memory %s not found", name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
*pHM = (pHistMem) pCom->pData;
if (!iHasType(*pHM, "HistMem")) {
sprintf(pBueffel, "ERROR: %s is no histogram memory!", name);
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s is no histogram memory!", name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -310,7 +310,7 @@ static int checkHM(pHistMem * pHM, SicsInterp * pSics, SConnection * pCon,
*/
GetHistDim(*pHM, iDim, &nDim);
if (nDim < 2) {
sprintf(pBueffel, "ERROR: %s is not 2 dimensional!", name);
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s is not 2 dimensional!", name);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -344,7 +344,7 @@ int LoMaxAction(SConnection * pCon, SicsInterp * pSics,
we need arguments
*/
if (argc < 2) {
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);
return 0;
@ -356,7 +356,7 @@ int LoMaxAction(SConnection * pCon, SicsInterp * pSics,
strtolower(argv[1]);
if (strcmp(argv[1], "search") == 0) {
if (argc < 3) {
sprintf(pBueffel,
snprintf(pBueffel,sizeof(pBueffel)-1,
"ERROR: insufficient number of arguments to %s.search",
argv[0]);
SCWrite(pCon, pBueffel, eError);
@ -380,11 +380,11 @@ int LoMaxAction(SConnection * pCon, SicsInterp * pSics,
if (count != 0) {
Tcl_DStringAppend(&result, "@", strlen("@"));
}
sprintf(pNum, "%d ", i);
snprintf(pNum,sizeof(pNum)-1, "%d ", i);
Tcl_DStringAppend(&result, pNum, strlen(pNum));
sprintf(pNum, "%d ", j);
snprintf(pNum,sizeof(pNum)-1, "%d ", j);
Tcl_DStringAppend(&result, pNum, strlen(pNum));
sprintf(pNum, "%d", intensity);
snprintf(pNum,sizeof(pNum)-1, "%d", intensity);
Tcl_DStringAppend(&result, pNum, strlen(pNum));
count++;
}
@ -395,7 +395,7 @@ int LoMaxAction(SConnection * pCon, SicsInterp * pSics,
return 1;
} else if (strcmp(argv[1], "cog") == 0) { /* COG calculation */
if (argc < 5) {
sprintf(pBueffel,
snprintf(pBueffel,sizeof(pBueffel)-1,
"ERROR: insufficient number of arguments to %s.cog",
argv[0]);
SCWrite(pCon, pBueffel, eError);
@ -405,12 +405,12 @@ int LoMaxAction(SConnection * pCon, SicsInterp * pSics,
return 0;
}
if (Tcl_GetInt(pSics->pTcl, argv[3], &i) != TCL_OK) {
sprintf(pBueffel, "ERROR: expected number, got %s", argv[2]);
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: expected number, got %s", argv[2]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
if (Tcl_GetInt(pSics->pTcl, argv[4], &j) != TCL_OK) {
sprintf(pBueffel, "ERROR: expected number, got %s", argv[2]);
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: expected number, got %s", argv[2]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -424,20 +424,20 @@ int LoMaxAction(SConnection * pCon, SicsInterp * pSics,
SCWrite(pCon, "ERROR: no intensity in data", eError);
return 0;
}
sprintf(pNum, "%d ", i);
snprintf(pNum,sizeof(pNum)-1, "%d ", i);
Tcl_DStringAppend(&result, pNum, strlen(pNum));
sprintf(pNum, "%d ", j);
snprintf(pNum,sizeof(pNum)-1, "%d ", j);
Tcl_DStringAppend(&result, pNum, strlen(pNum));
sprintf(pNum, "%d ", intensity);
snprintf(pNum,sizeof(pNum)-1, "%d ", intensity);
Tcl_DStringAppend(&result, pNum, strlen(pNum));
sprintf(pNum, "%d ", count);
snprintf(pNum,sizeof(pNum)-1, "%d ", count);
Tcl_DStringAppend(&result, pNum, strlen(pNum));
SCWrite(pCon, Tcl_DStringValue(&result), eValue);
Tcl_DStringFree(&result);
return 1;
} else if (strcmp(argv[1], "wellformed") == 0) { /* test for wellformedness */
if (argc < 6) {
sprintf(pBueffel,
snprintf(pBueffel,sizeof(pBueffel)-1,
"ERROR: insufficient number of arguments to %s.wellformed",
argv[0]);
SCWrite(pCon, pBueffel, eError);
@ -447,17 +447,17 @@ int LoMaxAction(SConnection * pCon, SicsInterp * pSics,
return 0;
}
if (Tcl_GetInt(pSics->pTcl, argv[3], &i) != TCL_OK) {
sprintf(pBueffel, "ERROR: expected number, got %s", argv[2]);
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: expected number, got %s", argv[2]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
if (Tcl_GetInt(pSics->pTcl, argv[4], &j) != TCL_OK) {
sprintf(pBueffel, "ERROR: expected number, got %s", argv[2]);
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: expected number, got %s", argv[2]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
if (Tcl_GetInt(pSics->pTcl, argv[5], &badMax) != TCL_OK) {
sprintf(pBueffel, "ERROR: expected number, got %s", argv[2]);
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: expected number, got %s", argv[2]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -465,12 +465,12 @@ int LoMaxAction(SConnection * pCon, SicsInterp * pSics,
window = (int) ObVal(self->pParam, COGWINDOW);
iRet = wellFormed(iData, iDim[0], iDim[1], i, j,
window, ObVal(self->pParam, COGCONTOUR), badMax);
sprintf(pBueffel, "%5d", iRet);
snprintf(pBueffel,sizeof(pBueffel)-1, "%5d", iRet);
SCWrite(pCon, pBueffel, eValue);
return 1;
} else if (strcmp(argv[1], "stat") == 0) {
if (argc < 3) {
sprintf(pBueffel,
snprintf(pBueffel,sizeof(pBueffel)-1,
"ERROR: insufficient number of arguments to %s.search",
argv[0]);
SCWrite(pCon, pBueffel, eError);
@ -481,7 +481,7 @@ int LoMaxAction(SConnection * pCon, SicsInterp * pSics,
}
iData = GetHistogramPointer(pHM, pCon);
calculateStatistics(iData, iDim[0], iDim[1], &average, &maximum);
sprintf(pBueffel, " %f %f", average, maximum);
snprintf(pBueffel,sizeof(pBueffel)-1, " %f %f", average, maximum);
SCWrite(pCon, pBueffel, eValue);
return 1;
} else {
@ -489,7 +489,7 @@ int LoMaxAction(SConnection * pCon, SicsInterp * pSics,
*/
if (argc > 2) { /* set case */
if (Tcl_GetDouble(pSics->pTcl, argv[2], &dVal) != TCL_OK) {
sprintf(pBueffel, "ERROR: expected number, got %s", argv[2]);
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: expected number, got %s", argv[2]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
@ -498,12 +498,12 @@ int LoMaxAction(SConnection * pCon, SicsInterp * pSics,
ob = ObParFind(self->pParam, argv[1]);
if (!ob) {
sprintf(pBueffel, "ERROR: parameter %s not found or wrong command",
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: parameter %s not found or wrong command",
argv[1]);
SCWrite(pCon, pBueffel, eError);
return 0;
}
sprintf(pBueffel, "%s.%s = %f", argv[0], argv[1], ob->fVal);
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.%s = %f", argv[0], argv[1], ob->fVal);
SCWrite(pCon, pBueffel, eError);
return 1;
}