- 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:
62
mumo.c
62
mumo.c
@ -313,7 +313,7 @@ static void ListMulMot(char *name, SConnection * pCon, pMulMot self)
|
||||
char pMotName[132];
|
||||
pMotor pMot = NULL;
|
||||
|
||||
sprintf(pBueffel, "Status listing for %s", name);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "Status listing for %s", name);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
|
||||
/* scan through all aliases */
|
||||
@ -323,11 +323,11 @@ static void ListMulMot(char *name, SConnection * pCon, pMulMot self)
|
||||
assert(pMot); /* has been tested on definition */
|
||||
iRet = MotorGetSoftPosition(pMot, pCon, &fVal);
|
||||
if (!iRet) {
|
||||
sprintf(pBueffel, "ERROR: Cannot read motor %s\n", pMotName);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: Cannot read motor %s\n", pMotName);
|
||||
eOut = eError;
|
||||
} else {
|
||||
eOut = eValue;
|
||||
sprintf(pBueffel, "%s.%s = %f\n", name, pNam, fVal);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.%s = %f\n", name, pNam, fVal);
|
||||
}
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
pNam = StringDictGetNext(self->pAlias, pMotName, 131);
|
||||
@ -353,7 +353,7 @@ static int ParseAlias(psParser pParse, SConnection * pCon, pMulMot self)
|
||||
iRet = StringDictGet(self->pAlias, pParse->Token, pBueffel, 131);
|
||||
/* that it is alias has been tested earlier */
|
||||
assert(iRet == 1);
|
||||
strcat(pCommand, pBueffel);
|
||||
strncat(pCommand, pBueffel,1024);
|
||||
|
||||
/* now find the value to handle */
|
||||
iToken = GetNextToken(pParse, self);
|
||||
@ -383,20 +383,20 @@ static int ParseAlias(psParser pParse, SConnection * pCon, pMulMot self)
|
||||
assert(pMot); /* existence shoul have been verified earlier */
|
||||
MotorGetSoftPosition(pMot, pCon, &fVal);
|
||||
fVal += iSign * fIn;
|
||||
sprintf(pBueffel, " %f ", fVal);
|
||||
strcat(pCommand, pBueffel);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, " %f ", fVal);
|
||||
strncat(pCommand, pBueffel,1024);
|
||||
InterpExecute(GetInterpreter(), pCon, pCommand);
|
||||
return 1;
|
||||
} else {
|
||||
sprintf(pBueffel, " %f ", iSign * fIn);
|
||||
strcat(pCommand, pBueffel);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, " %f ", iSign * fIn);
|
||||
strncat(pCommand, pBueffel,1024);
|
||||
InterpExecute(GetInterpreter(), pCon, pCommand);
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
sprintf(pBueffel, "ERROR: Unexpected symbol %s", pParse->Token);
|
||||
snprintf(pBueffel,1024, "ERROR: Unexpected symbol %s", pParse->Token);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -426,18 +426,18 @@ static int MakeCurrentNamPos(char *name, SConnection * pCon, pMulMot self)
|
||||
pCommand[0] = '\0';
|
||||
pAlias = StringDictGetNext(self->pAlias, pMotort, 131);
|
||||
while (pAlias != NULL) {
|
||||
strcat(pCommand, pMotort);
|
||||
strncat(pCommand, pMotort,1024);
|
||||
pMot = FindMotor(GetInterpreter(), pMotort);
|
||||
assert(pMot); /* validity of alias has already been checked */
|
||||
iRet = MotorGetSoftPosition(pMot, pCon, &fVal);
|
||||
if (!iRet) {
|
||||
sprintf(pCommand, "ERROR: failure to read motor %s, %s",
|
||||
snprintf(pCommand,1024, "ERROR: failure to read motor %s, %s",
|
||||
pMotort, " named position not created");
|
||||
SCWrite(pCon, pCommand, eError);
|
||||
return 0;
|
||||
}
|
||||
sprintf(pMotort, " %f ", fVal);
|
||||
strcat(pCommand, pMotort);
|
||||
snprintf(pMotort,sizeof(pMotort)-1, " %f ", fVal);
|
||||
strncat(pCommand, pMotort,1024);
|
||||
pAlias = StringDictGetNext(self->pAlias, pMotort, 131);
|
||||
}
|
||||
if (StringDictExists(self->pNamPos, name)) {
|
||||
@ -480,7 +480,7 @@ const char *FindNamPos(pMulMot self, SConnection * pCon)
|
||||
if (pMot != NULL) {
|
||||
iRet = MotorGetSoftPosition(pMot, pCon, &f1);
|
||||
if (!iRet) {
|
||||
sprintf(pTestCommand,
|
||||
snprintf(pTestCommand,sizeof(pTestCommand)-1,
|
||||
"ERROR: failed to get motor position for %s", pName);
|
||||
SCWrite(pCon, pTestCommand, eError);
|
||||
return NULL;
|
||||
@ -563,7 +563,7 @@ static int ParseDropPos(psParser pParse, SConnection * pCon, pMulMot self)
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
sprintf(pBueffel, "ERROR: Unexpected symbol %s", pParse->Token);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: Unexpected symbol %s", pParse->Token);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -581,7 +581,7 @@ static int CheckPermission(SConnection * pCon, pMulMot self)
|
||||
if (SCMatchRights(pCon, iAccess)) {
|
||||
return 1;
|
||||
} else {
|
||||
sprintf(pBueffel, "ERROR: NO permission to drive %s", self->name);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: NO permission to drive %s", self->name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -609,7 +609,7 @@ static int ParseNamPos(psParser pParse, SConnection * pCon,
|
||||
InterpExecute(GetInterpreter(), pCon, pCommand);
|
||||
return 1;
|
||||
} else {
|
||||
sprintf(pCommand, "ERROR: named position %s NOT found", pParse->Token);
|
||||
snprintf(pCommand,sizeof(pCommand)-1, "ERROR: named position %s NOT found", pParse->Token);
|
||||
SCWrite(pCon, pCommand, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -628,7 +628,7 @@ static int ParseDefPos(SicsInterp * pSics, psParser pPP,
|
||||
|
||||
iToken = GetNextToken(pPP, self);
|
||||
if (iToken != SYMBOL) { /* we want a name here */
|
||||
sprintf(pError, "ERROR: Invalid Token %s in ParsePos", pPP->Token);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: Invalid Token %s in ParsePos", pPP->Token);
|
||||
SCWrite(pCon, pError, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -638,21 +638,21 @@ static int ParseDefPos(SicsInterp * pSics, psParser pPP,
|
||||
command[0] = '\0';
|
||||
while (iToken != END) {
|
||||
if (iToken != ALIAS) {
|
||||
sprintf(command, "ERROR: expected motor alias, got: %s", pPP->Token);
|
||||
snprintf(command,sizeof(command)-1, "ERROR: expected motor alias, got: %s", pPP->Token);
|
||||
SCWrite(pCon, command, eError);
|
||||
return 0;
|
||||
}
|
||||
StringDictGet(self->pAlias, pPP->Token, motorName, 79);
|
||||
strcat(command, motorName);
|
||||
strcat(command, " ");
|
||||
strncat(command, motorName,1024);
|
||||
strncat(command, " ",1024);
|
||||
iToken = GetNextToken(pPP, self);
|
||||
if (iToken != NUMBER) {
|
||||
sprintf(command, "ERROR: expected number, got: %s", pPP->Token);
|
||||
snprintf(command,sizeof(command)-1, "ERROR: expected number, got: %s", pPP->Token);
|
||||
SCWrite(pCon, command, eError);
|
||||
return 0;
|
||||
}
|
||||
strcat(command, pPP->Token);
|
||||
strcat(command, " ");
|
||||
strncat(command, pPP->Token,1024);
|
||||
strncat(command, " ",1024);
|
||||
iToken = GetNextToken(pPP, self);
|
||||
}
|
||||
|
||||
@ -770,9 +770,9 @@ int MultiWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
case GETPOS:
|
||||
pPtr = FindNamPos(self, pCon);
|
||||
if (pPtr != NULL) {
|
||||
sprintf(pBueffel, "%s.nampos = %s", argv[0], pPtr);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.nampos = %s", argv[0], pPtr);
|
||||
} else {
|
||||
sprintf(pBueffel, "%s.nampos = undefined", argv[0]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.nampos = undefined", argv[0]);
|
||||
}
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
return 1;
|
||||
@ -783,7 +783,7 @@ int MultiWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
case LIST:
|
||||
pPtr = NULL;
|
||||
Tcl_DStringInit(&tString);
|
||||
sprintf(pBueffel, "%s list of known named positions \n", argv[0]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s list of known named positions \n", argv[0]);
|
||||
Tcl_DStringAppend(&tString, pBueffel, strlen(pBueffel));
|
||||
StringDictKillScan(self->pNamPos);
|
||||
pPtr = StringDictGetNext(self->pNamPos, pError, 131);
|
||||
@ -808,7 +808,7 @@ int MultiWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCparChange(pCon);
|
||||
return 1;
|
||||
} else {
|
||||
sprintf(pError, "ERROR: %s no valid named position name",
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: %s no valid named position name",
|
||||
MyParser.Token);
|
||||
SCWrite(pCon, pError, eError);
|
||||
return 0;
|
||||
@ -828,14 +828,14 @@ int MultiWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
pPtr = NULL;
|
||||
pPtr = FindNamPos(self, pCon);
|
||||
if (pPtr) {
|
||||
sprintf(pBueffel, "%s.namedposition = %s", argv[0], pPtr);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.namedposition = %s", argv[0], pPtr);
|
||||
} else {
|
||||
sprintf(pBueffel, "%s.namedposition = UNKNOWN", argv[0]);
|
||||
snprintf(pBueffel,sizeof(pBueffel)-1, "%s.namedposition = UNKNOWN", argv[0]);
|
||||
}
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
return 1;
|
||||
}
|
||||
sprintf(pError, "ERROR: Unknown Token %s", MyParser.Token);
|
||||
snprintf(pError,sizeof(pError)-1, "ERROR: Unknown Token %s", MyParser.Token);
|
||||
SCWrite(pCon, pError, eError);
|
||||
return 0;
|
||||
case RECOVERNAMPOS:
|
||||
|
Reference in New Issue
Block a user