Check number of args on scan run and silent commands to prevent segfaults.

r1103 | ffr | 2006-09-04 12:03:53 +1000 (Mon, 04 Sep 2006) | 2 lines
This commit is contained in:
Ferdi Franceschini
2006-09-04 12:03:53 +10:00
committed by Douglas Clowes
parent 6ae1d3548d
commit b95d1d8da7

12
scan.c
View File

@@ -1540,7 +1540,7 @@ static int PrintCountsOrMonitors(pScanData self, SConnection *pCon,
if(iWhich < 0) if(iWhich < 0)
{ {
GetScanCounts(self,lData,self->iNP); GetScanCounts(self,lData,self->iNP);
snprintf(pBueffel,59,"%s.counts = {", name); snprintf(pBueffel,59,"%s.Counts = {", name);
} }
else else
{ {
@@ -2133,6 +2133,11 @@ static int DumpScan(pScanData self, SConnection *pCon)
/*---------- scan */ /*---------- scan */
else if(strcmp(argv[1],"run") == 0) else if(strcmp(argv[1],"run") == 0)
{ {
if (argc < 5) {
sprintf(pBueffel,"ERROR: not enough arguments for %s run",argv[0]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
/* get NP */ /* get NP */
iRet = Tcl_GetInt(InterpGetTcl(pSics),argv[2],&lNP); iRet = Tcl_GetInt(InterpGetTcl(pSics),argv[2],&lNP);
if(iRet != TCL_OK) if(iRet != TCL_OK)
@@ -2181,6 +2186,11 @@ static int DumpScan(pScanData self, SConnection *pCon)
/*---------- silent */ /*---------- silent */
else if(strcmp(argv[1],"silent") == 0) else if(strcmp(argv[1],"silent") == 0)
{ {
if (argc < 5) {
sprintf(pBueffel,"ERROR: not enough arguments for %s silent",argv[0]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
/* get NP */ /* get NP */
iRet = Tcl_GetInt(InterpGetTcl(pSics),argv[2],&lNP); iRet = Tcl_GetInt(InterpGetTcl(pSics),argv[2],&lNP);
if(iRet != TCL_OK) if(iRet != TCL_OK)