add buffer overflow protection to MQueueDiagnose()

git-svn-id: svn://opensvn.adaptivecomputing.com/maui/trunk@32 3f5042e3-fb1d-0410-be18-d6ca2573e517
This commit is contained in:
dev 2005-09-16 12:54:10 +00:00
parent 1b4c4d0fd4
commit 2625ed201d
4 changed files with 15 additions and 6 deletions

View File

@ -380,7 +380,7 @@ int MQueuePrioritizeJobs(mjob_t **,int *);
int MQueueGetBestRQTime(int *,long *);
int MQueueScheduleRJobs(int *);
int MQueueScheduleSJobs(int *);
int MQueueDiagnose(mjob_t **,int *,int,mpar_t *,char *);
int MQueueDiagnose(mjob_t **,int *,int,mpar_t *,char *,int);
int MQueueCheckStatus(void);
int MQueueGetRequeueValue(int *,long,long,double *);
int MQueueSelectAllJobs(mjob_t **,int,mpar_t *,int *,int,int,int,char *);

View File

@ -1 +1 @@
#define MSCHED_VERSION "maui-3.2.6p14-snap.1125680408"
#define MSCHED_VERSION "maui-3.2.6p14-snap.1126543721"

View File

@ -925,7 +925,8 @@ int MQueueDiagnose(
int *NBJobList,
int PLevel,
mpar_t *PS,
char *Buffer)
char *Buffer,
int BufSize)
{
int pindex;
@ -977,6 +978,9 @@ int MQueueDiagnose(
for (J = FullQ[0]->Next;J != FullQ[0];J = J->Next)
{
if (strlen(Buffer) + 256 >= BufSize)
break;
if ((PS->Index > 0) && (MUBMCheck(PS->Index,J->PAL) == FAILURE))
continue;
@ -1183,7 +1187,7 @@ int MQueueDiagnose(
if (IsBlocked == FALSE)
{
switch(J->BlockReason)
switch (J->BlockReason)
{
case mjneIdlePolicy:
@ -1205,7 +1209,12 @@ int MQueueDiagnose(
break;
} /* END switch(J->BlockReason) */
}
} /* END for (jindex) */
}
if (J != FullQ[0])
{
strcat(Buffer,"\nlist truncated\n");
}
return(SUCCESS);
} /* END MQueueDiagnose() */

View File

@ -3739,7 +3739,7 @@ int UIQueueDiagnose(
MPolicyMode[PLevel],
MAList[ePartition][PIndex]);
if (MQueueDiagnose(MJob,MUIQ,PLevel,&MPar[PIndex],Buffer) == FAILURE)
if (MQueueDiagnose(MJob,MUIQ,PLevel,&MPar[PIndex],Buffer,*BufSize) == FAILURE)
{
sprintf(Buffer,"cannot evaluate blocked jobs\n");