- 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

@ -270,14 +270,14 @@ static int TASUBHeader(pScanData self)
/*
build the steps line
*/
sprintf(pBueffel, "STEPS: ");
snprintf(pBueffel,sizeof(pBueffel)-1, "STEPS: ");
for (i = 0; i < self->iScanVar; i++) {
DynarGet(self->pScanVar, i, &pPtr);
pVar = (pVarEntry) pPtr;
if (pVar) {
strncpy(pWork2, ScanVarName(pVar), 59);
strtoupper(pWork2);
sprintf(pWork, "D%s=%8.4f, ", pWork2, ScanVarStep(pVar));
snprintf(pWork,sizeof(pWork)-1, "D%s=%8.4f, ", pWork2, ScanVarStep(pVar));
strcat(pBueffel, pWork);
}
}
@ -399,7 +399,7 @@ static int TASUBHeader(pScanData self)
iCount = 0;
fprintf(self->fd, "\nVARIA: ");
}
strcpy(pWork2, pCom->pName);
strncpy(pWork2, pCom->pName,60);
strtoupper(pWork2);
fprintf(self->fd, "%-8s=%8.4f, ", pWork2, fVal);
iCount++;
@ -430,7 +430,7 @@ static int TASUBHeader(pScanData self)
iCount = 0;
fprintf(self->fd, "\nZEROS: ");
}
strcpy(pWork2, pCom->pName);
strncpy(pWork2, pCom->pName,60);
strtoupper(pWork2);
fprintf(self->fd, "%-8s=%8.4f, ", pWork2, fVal);
iCount++;
@ -485,11 +485,11 @@ static int TASUBHeader(pScanData self)
DynarGet(self->pScanVar, i, &pPtr);
pVar = (pVarEntry) pPtr;
if (pVar) {
strcat(pBueffel, "F9.4,1X,");
strncat(pBueffel, "F9.4,1X,",1024);
strncpy(pWork2, pVar->Name, 59);
strtoupper(pWork2);
strcenter(pWork2, pTen, 11);
strcat(pHeader, pTen);
strncat(pHeader, pTen,1024);
}
}
/*
@ -502,16 +502,16 @@ static int TASUBHeader(pScanData self)
*/
for (i = 0; i < pTAS->addCount; i++) {
if (i == pTAS->addCount - 1) {
strcat(pBueffel, "F9.4");
strncat(pBueffel, "F9.4",1024);
} else {
strcat(pBueffel, "F9.4,1X,");
strncat(pBueffel, "F9.4,1X,",1024);
}
strcpy(pWork2, pTAS->out[i]);
strncpy(pWork2, pTAS->out[i],60);
strtoupper(pWork2);
strcenter(pWork2, pTen, 11);
strcat(pHeader, pTen);
strncat(pHeader, pTen,1024);
}
strcat(pBueffel, ")");
strncat(pBueffel, ")",1024);
/*
write the final bit
@ -566,9 +566,9 @@ static int TASUBScanPoint(pScanData self, int iPoint)
write point number
*/
if (pTAS->iPOL >= 0) {
sprintf(pBueffel, "%3d %3d", iPoint + 1, pTAS->iPOL);
snprintf(pBueffel,sizeof(pBueffel)-1, "%3d %3d", iPoint + 1, pTAS->iPOL);
} else {
sprintf(pBueffel, "%4d ", iPoint + 1);
snprintf(pBueffel,sizeof(pBueffel)-1, "%4d ", iPoint + 1);
}
/*
@ -580,7 +580,7 @@ static int TASUBScanPoint(pScanData self, int iPoint)
if (pVar) {
fVal = readDrivable(ScanVarName(pVar), self->pCon);
}
sprintf(pWork, "%9.4f ", fVal);
snprintf(pWork,sizeof(pWork)-1, "%9.4f ", fVal);
strcat(pBueffel, pWork);
}
@ -592,7 +592,7 @@ static int TASUBScanPoint(pScanData self, int iPoint)
m3 = GetMonitor(self->pCounterData, 3, self->pCon);
cnts = GetCounts(self->pCounterData, self->pCon);
fVal = GetCountTime(self->pCounterData, self->pCon);
sprintf(pWork, "%8ld %8ld %9.2f %8ld %8ld ", m1, m2, fVal, cnts, m3);
snprintf(pWork,sizeof(pWork)-1, "%8ld %8ld %9.2f %8ld %8ld ", m1, m2, fVal, cnts, m3);
strcat(pBueffel, pWork);
/*
@ -605,7 +605,7 @@ static int TASUBScanPoint(pScanData self, int iPoint)
snprintf(pError, 131, "WARNING: problem reading %s", pTAS->out[i]);
SCWrite(self->pCon, pError, eWarning);
}
sprintf(pWork, "%9.4f ", fVal);
snprintf(pWork,sizeof(pWork)-1, "%9.4f ", fVal);
strcat(pBueffel, pWork);
}
@ -872,7 +872,7 @@ static void ParseOutput(pTASdata pTAS, SConnection * pCon)
} else {
strtolower(pToken);
if (strcmp(pToken, "unknown") != 0) {
sprintf(pWarn, "WARNING: ignored invalid token > %s < in output",
snprintf(pWarn,sizeof(pWarn)-1, "WARNING: ignored invalid token > %s < in output",
pToken);
SCWrite(pCon, pWarn, eWarning);
}
@ -908,10 +908,10 @@ int TASUBPrepare(pScanData self)
SCWrite(self->pCon, pLine, eLog);
if (GetCounterMode(pTAS->pScan->pCounterData) == eTimer) {
sprintf(pLine, " %8f Seconds per point",
snprintf(pLine,sizeof(pLine)-1, " %8f Seconds per point",
GetCounterPreset(pTAS->pScan->pCounterData));
} else {
sprintf(pLine, " %8f Monitor Counts per point",
snprintf(pLine,sizeof(pLine)-1, " %8f Monitor Counts per point",
GetCounterPreset(pTAS->pScan->pCounterData));
}