- 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:
48
hklscan.c
48
hklscan.c
@@ -71,7 +71,7 @@ int HklscanFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
/* find scan object */
|
||||
pNew->pScan = (pScanData) FindCommandData(pSics, argv[1], "ScanObject");
|
||||
if (!pNew->pScan) {
|
||||
sprintf(pBueffel, "ERROR: %s not found or no scan object", argv[1]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s not found or no scan object", argv[1]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
KillHklscan(pNew);
|
||||
return 0;
|
||||
@@ -81,7 +81,7 @@ int HklscanFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
pNew->pCalc = (pHKL) FindCommandData(pSics, argv[2],
|
||||
"4-Circle-Calculus");
|
||||
if (!pNew->pCalc) {
|
||||
sprintf(pBueffel, "ERROR: %s not found or no HKL object", argv[2]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s not found or no HKL object", argv[2]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
KillHklscan(pNew);
|
||||
return 0;
|
||||
@@ -152,45 +152,45 @@ static int WriteHklscanPoint(pScanData self, int iPoint)
|
||||
}
|
||||
|
||||
/* make the data header */
|
||||
sprintf(pLine, "%-5s", "NP");
|
||||
sprintf(pInfo, "Scanning Variables: H, K, L STEP: %8.3f %8.3f %8.3f",
|
||||
snprintf(pLine,sizeof(pLine)-1, "%-5s", "NP");
|
||||
snprintf(pInfo,sizeof(pInfo)-1, "Scanning Variables: H, K, L STEP: %8.3f %8.3f %8.3f",
|
||||
pHaSca->fStep[0], pHaSca->fStep[1], pHaSca->fStep[2]);
|
||||
strcat(pLine, "H K L ");
|
||||
for (i = 0; i < self->iScanVar; i++) {
|
||||
DynarGet(self->pScanVar, i, &pPtr);
|
||||
pVar = (pVarEntry) pPtr;
|
||||
if (pVar) {
|
||||
sprintf(pItem, "%-6.6s ", pVar->Name);
|
||||
snprintf(pItem,sizeof(pItem)-1, "%-6.6s ", pVar->Name);
|
||||
strcat(pLine, pItem);
|
||||
}
|
||||
}
|
||||
strcat(pLine, "Counts ");
|
||||
strcat(pLine, " Monitor1 ");
|
||||
sprintf(pItem, "\n%d Points,", self->iNP);
|
||||
snprintf(pItem,sizeof(pItem)-1, "\n%d Points,", self->iNP);
|
||||
strcat(pInfo, pItem);
|
||||
if (self->iMode == eTimer) {
|
||||
strcat(pInfo, " Mode: Timer,");
|
||||
} else {
|
||||
strcat(pInfo, " Mode: Monitor,");
|
||||
}
|
||||
sprintf(pItem, " Preset %f", self->fPreset);
|
||||
snprintf(pItem,sizeof(pItem)-1, " Preset %f", self->fPreset);
|
||||
strcat(pInfo, pItem);
|
||||
fprintf(self->fd, "%s\n", pInfo);
|
||||
fprintf(self->fd, "%s\n", pLine);
|
||||
|
||||
/* print an addon to the status line going to the screen */
|
||||
sprintf(pLine, "NP H K L ");
|
||||
snprintf(pLine,sizeof(pLine)-1, "NP H K L ");
|
||||
SCWrite(self->pCon, pLine, eWarning);
|
||||
sprintf(pLine, "%-5d%-8.4f%-8.4f%-8.4f ", iPoint, pHaSca->fPos[0],
|
||||
snprintf(pLine,sizeof(pLine)-1, "%-5d%-8.4f%-8.4f%-8.4f ", iPoint, pHaSca->fPos[0],
|
||||
pHaSca->fPos[1], pHaSca->fPos[2]);
|
||||
SCWrite(self->pCon, pLine, eWarning);
|
||||
|
||||
/* now the scan points */
|
||||
for (i = 0; i < self->iCounts; i++) {
|
||||
sprintf(pLine, "%-5d", i);
|
||||
snprintf(pLine,sizeof(pLine)-1, "%-5d", i);
|
||||
/* print HKL */
|
||||
for (i2 = 0; i2 < 3; i2++) {
|
||||
sprintf(pItem, " %-8.4f",
|
||||
snprintf(pItem,sizeof(pItem)-1, " %-8.4f",
|
||||
pHaSca->fStart[i2] + i * pHaSca->fStep[i2]);
|
||||
strcat(pLine, pItem);
|
||||
}
|
||||
@@ -199,7 +199,7 @@ static int WriteHklscanPoint(pScanData self, int iPoint)
|
||||
DynarGet(self->pScanVar, i2, &pPtr);
|
||||
pVar = (pVarEntry) pPtr;
|
||||
if (pVar) {
|
||||
sprintf(pItem, " %-7.2f", GetScanVarPos(pVar, i));
|
||||
snprintf(pItem,sizeof(pItem)-1, " %-7.2f", GetScanVarPos(pVar, i));
|
||||
strcat(pLine, pItem);
|
||||
}
|
||||
}
|
||||
@@ -207,9 +207,9 @@ static int WriteHklscanPoint(pScanData self, int iPoint)
|
||||
DynarGet(self->pCounts, i, &pPtr);
|
||||
pData = (pCountEntry) pPtr;
|
||||
if (pData) {
|
||||
sprintf(pItem, " %-13ld", pData->lCount);
|
||||
snprintf(pItem,sizeof(pItem)-1, " %-13ld", pData->lCount);
|
||||
strcat(pLine, pItem);
|
||||
sprintf(pItem, " %-12ld", pData->Monitors[0]);
|
||||
snprintf(pItem,sizeof(pItem)-1, " %-12ld", pData->Monitors[0]);
|
||||
strcat(pLine, pItem);
|
||||
}
|
||||
fprintf(self->fd, "%s\n", pLine);
|
||||
@@ -302,21 +302,21 @@ int HklscanAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
iRet = Tcl_GetDouble(pSics->pTcl, argv[2], &dVal);
|
||||
if (iRet != TCL_OK) {
|
||||
sprintf(pBueffel, "ERROR: failed to convert %s to number", argv[2]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: failed to convert %s to number", argv[2]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
self->fStart[0] = (float) dVal;
|
||||
iRet = Tcl_GetDouble(pSics->pTcl, argv[3], &dVal);
|
||||
if (iRet != TCL_OK) {
|
||||
sprintf(pBueffel, "ERROR: failed to convert %s to number", argv[3]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: failed to convert %s to number", argv[3]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
self->fStart[1] = (float) dVal;
|
||||
iRet = Tcl_GetDouble(pSics->pTcl, argv[4], &dVal);
|
||||
if (iRet != TCL_OK) {
|
||||
sprintf(pBueffel, "ERROR: failed to convert %s to number", argv[4]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: failed to convert %s to number", argv[4]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@@ -334,21 +334,21 @@ int HklscanAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
iRet = Tcl_GetDouble(pSics->pTcl, argv[2], &dVal);
|
||||
if (iRet != TCL_OK) {
|
||||
sprintf(pBueffel, "ERROR: failed to convert %s to number", argv[2]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: failed to convert %s to number", argv[2]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
self->fStep[0] = (float) dVal;
|
||||
iRet = Tcl_GetDouble(pSics->pTcl, argv[3], &dVal);
|
||||
if (iRet != TCL_OK) {
|
||||
sprintf(pBueffel, "ERROR: failed to convert %s to number", argv[3]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: failed to convert %s to number", argv[3]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
self->fStep[1] = (float) dVal;
|
||||
iRet = Tcl_GetDouble(pSics->pTcl, argv[4], &dVal);
|
||||
if (iRet != TCL_OK) {
|
||||
sprintf(pBueffel, "ERROR: failed to convert %s to number", argv[4]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: failed to convert %s to number", argv[4]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@@ -366,7 +366,7 @@ int HklscanAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
iRet = Tcl_GetInt(pSics->pTcl, argv[2], &iNP);
|
||||
if (iRet != TCL_OK) {
|
||||
sprintf(pBueffel, "ERROR: failed to convert %s to number", argv[2]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: failed to convert %s to number", argv[2]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@@ -376,7 +376,7 @@ int HklscanAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
} else if (strcmp(argv[3], "monitor") == 0) {
|
||||
iMode = ePreset;
|
||||
} else {
|
||||
sprintf(pBueffel, "ERROR: %s not recognized as valid counter mode",
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: %s not recognized as valid counter mode",
|
||||
argv[3]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
@@ -384,7 +384,7 @@ int HklscanAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
/* preset */
|
||||
iRet = Tcl_GetDouble(pSics->pTcl, argv[4], &dVal);
|
||||
if (iRet != TCL_OK) {
|
||||
sprintf(pBueffel, "ERROR: expected number, got %s", argv[3]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: expected number, got %s", argv[3]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@@ -395,7 +395,7 @@ int HklscanAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
return iRet;
|
||||
}
|
||||
sprintf(pBueffel,
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1,
|
||||
"ERROR: %s not recognized as command word to hklscan", argv[1]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user