fix for a buffer overflow
git-svn-id: svn://opensvn.adaptivecomputing.com/maui/trunk@70 3f5042e3-fb1d-0410-be18-d6ca2573e517
This commit is contained in:
parent
84d58a74bd
commit
f07c10a297
@ -298,7 +298,7 @@ int MJobSelectMNL(mjob_t *,mpar_t *,nodelist_t,mnodelist_t,char *,int);
|
||||
int MJobDistributeTasks(mjob_t *,mrm_t *,mnalloc_t *,short *);
|
||||
int MJobTrap(mjob_t *);
|
||||
char *MJobGetName(mjob_t *,char *,mrm_t *,char *,int,enum MJobNameEnum);
|
||||
int MJobGetStartPriority(mjob_t *,int,double *,int,char *);
|
||||
int MJobGetStartPriority(mjob_t *,int,double *,int,char **,int *);
|
||||
int MJobGetRunPriority(mjob_t *,int,double *,char *);
|
||||
int MJobGetBackfillPriority(mjob_t *,unsigned long,int,double *,char *);
|
||||
int MJobGetPartitionAccess(mjob_t *);
|
||||
|
@ -1122,9 +1122,9 @@ typedef struct {
|
||||
int (*ResourceQuery)(mnode_t *,mrm_t *,char *,int *);
|
||||
int (*RMEventQuery)(mrm_t *,int *);
|
||||
int (*RMGetData)(mrm_t *,int *);
|
||||
int (*RMInitialize)(mrm_t *, int *);
|
||||
int (*RMInitialize)(mrm_t *,int *);
|
||||
int (*RMQuery)(void);
|
||||
int (*WorkloadQuery)(mrm_t *, int *, int *);
|
||||
int (*WorkloadQuery)(mrm_t *,int *,int *);
|
||||
|
||||
mbool_t IsInitialized;
|
||||
} mrmfunc_t;
|
||||
@ -1827,7 +1827,7 @@ typedef struct {
|
||||
int (*JobDistributeTasks)(mjob_t *,mrm_t *,mnalloc_t *,short int *);
|
||||
int (*JobFind)(char *, mjob_t **, int);
|
||||
int (*JobGetFeasibleTasks)(mjob_t *,mreq_t *,mpar_t *,nodelist_t,nodelist_t,int *,int *,long int,long unsigned int);
|
||||
int (*JobGetStartPriority)(mjob_t *,int,double *,int,char *);
|
||||
int (*JobGetStartPriority)(mjob_t *,int,double *,int,char **,int *);
|
||||
int (*JobGetTasks)(mjob_t *,mpar_t *,nodelist_t,mnodelist_t,char *,int);
|
||||
int (*JobSetCreds)(mjob_t *, char *, char *, char *);
|
||||
int (*JobSetQOS)(mjob_t *, mqos_t *, int);
|
||||
|
@ -32,7 +32,8 @@ int MJobGetStartPriority(
|
||||
int PIndex, /* I */
|
||||
double *Priority, /* O */
|
||||
int Mode, /* I */
|
||||
char *Buffer) /* O (optional,minsize=MMAX_BUFFER) */
|
||||
char **BPtr, /* O (optional,minsize=MMAX_BUFFER) */
|
||||
int *BSpace) /* O (optional) */
|
||||
|
||||
{
|
||||
double Prio;
|
||||
@ -95,9 +96,6 @@ int MJobGetStartPriority(
|
||||
|
||||
unsigned long MinWCLimit;
|
||||
|
||||
char *BPtr;
|
||||
int BSpace;
|
||||
|
||||
const char *FName = "MJobGetStartPriority";
|
||||
|
||||
DBG(6,fSCHED) DPrint("%s(%s,%d,%s,%s)\n",
|
||||
@ -105,7 +103,7 @@ int MJobGetStartPriority(
|
||||
(J != NULL) ? J->Name : "[NONE]",
|
||||
PIndex,
|
||||
(Priority != NULL) ? "Priority" : "NULL",
|
||||
(Buffer != NULL) ? "Buffer" : "NULL");
|
||||
((BPtr != NULL) && (*BPtr != NULL)) ? "Buffer" : "NULL");
|
||||
|
||||
/* NOTE: NULL 'J' allowed */
|
||||
|
||||
@ -118,7 +116,7 @@ int MJobGetStartPriority(
|
||||
|
||||
if (X.XJobGetStartPriority != (int (*)())0)
|
||||
{
|
||||
return((*X.XJobGetStartPriority)(X.xd,J,Priority,Buffer));
|
||||
return((*X.XJobGetStartPriority)(X.xd,J,Priority,*BPtr));
|
||||
}
|
||||
|
||||
for (index = 1;index < MAX_MPRIOCOMPONENT;index++)
|
||||
@ -492,9 +490,7 @@ int MJobGetStartPriority(
|
||||
}
|
||||
} /* END if (CWeight[mpcUsage] != 0) */
|
||||
|
||||
MUSNInit(&BPtr,&BSpace,Buffer,MMAX_BUFFER);
|
||||
|
||||
MUSNPrintF(&BPtr,&BSpace,"%-20s %10s%c %*s%*s%*s%*s%*s%*s%*s\n",
|
||||
MUSNPrintF(BPtr,BSpace,"%-20s %10s%c %*s%*s%*s%*s%*s%*s%*s\n",
|
||||
"Job",
|
||||
"PRIORITY",
|
||||
'*',
|
||||
@ -513,7 +509,7 @@ int MJobGetStartPriority(
|
||||
(int)strlen(CHeader[mpcUsage]),
|
||||
CHeader[mpcUsage]);
|
||||
|
||||
MUSNPrintF(&BPtr,&BSpace,"%20s %10s%c %*s%*s%*s%*s%*s%*s%*s\n",
|
||||
MUSNPrintF(BPtr,BSpace,"%20s %10s%c %*s%*s%*s%*s%*s%*s%*s\n",
|
||||
"Weights",
|
||||
"--------",
|
||||
' ',
|
||||
@ -532,7 +528,7 @@ int MJobGetStartPriority(
|
||||
(int)strlen(CWLine[mpcUsage]),
|
||||
CWLine[mpcUsage]);
|
||||
|
||||
MUSNPrintF(&BPtr,&BSpace,"\n");
|
||||
MUSNPrintF(BPtr,BSpace,"\n");
|
||||
|
||||
DBG(5,fUI) DPrint("INFO: %s header created\n",
|
||||
FName);
|
||||
@ -646,9 +642,9 @@ int MJobGetStartPriority(
|
||||
}
|
||||
} /* END for (cindex) */
|
||||
|
||||
MUSNPrintF(&BPtr,&BSpace,"\n");
|
||||
MUSNPrintF(BPtr,BSpace,"\n");
|
||||
|
||||
MUSNPrintF(&BPtr,&BSpace,"%-20s %10s%c %*s%*s%*s%*s%*s%*s%*s\n",
|
||||
MUSNPrintF(BPtr,BSpace,"%-20s %10s%c %*s%*s%*s%*s%*s%*s%*s\n",
|
||||
"Percent Contribution",
|
||||
"--------",
|
||||
' ',
|
||||
@ -667,9 +663,9 @@ int MJobGetStartPriority(
|
||||
(int)strlen(CFooter[mpcUsage]),
|
||||
CFooter[mpcUsage]);
|
||||
|
||||
MUSNPrintF(&BPtr,&BSpace,"\n");
|
||||
MUSNPrintF(BPtr,BSpace,"\n");
|
||||
|
||||
MUSNPrintF(&BPtr,&BSpace,"* indicates system prio set on job\n");
|
||||
MUSNPrintF(BPtr,BSpace,"* indicates system prio set on job\n");
|
||||
|
||||
return(SUCCESS);
|
||||
} /* END if (Mode == 2) */
|
||||
@ -1122,7 +1118,7 @@ int MJobGetStartPriority(
|
||||
APrio += ABS((double)CWeight[index] * CFactor[index]);
|
||||
} /* END for (index) */
|
||||
|
||||
if (Buffer != NULL)
|
||||
if ((BPtr != NULL) && (*BPtr != NULL))
|
||||
{
|
||||
TotalPriority += APrio;
|
||||
|
||||
@ -1402,7 +1398,7 @@ int MJobGetStartPriority(
|
||||
}
|
||||
} /* END if (CWeight[mpcUsage] != 0) */
|
||||
|
||||
MUSNPrintF(&BPtr,&BSpace,"%-20s %10.0lf%c %*s%*s%*s%*s%*s%*s%*s\n",
|
||||
MUSNPrintF(BPtr,BSpace,"%-20s %10.0lf%c %*s%*s%*s%*s%*s%*s%*s\n",
|
||||
J->Name,
|
||||
Prio,
|
||||
(J->SystemPrio > 0) ? '*' : ' ',
|
||||
@ -1420,7 +1416,7 @@ int MJobGetStartPriority(
|
||||
CLine[mpcRes],
|
||||
(int)strlen(CLine[mpcUsage]),
|
||||
CLine[mpcUsage]);
|
||||
} /* END if (Buffer != NULL) */
|
||||
} /* END if (BPtr != NULL) */
|
||||
|
||||
/* clip prio at min value */
|
||||
|
||||
|
@ -91,7 +91,7 @@ int MQueuePrioritizeJobs(
|
||||
{
|
||||
J = MJob[JobIndex[jindex]];
|
||||
|
||||
MJobGetStartPriority(J,0,&tmpD,0,NULL);
|
||||
MJobGetStartPriority(J,0,&tmpD,0,NULL,NULL);
|
||||
|
||||
J->StartPriority = (unsigned long)tmpD;
|
||||
|
||||
@ -113,7 +113,7 @@ int MQueuePrioritizeJobs(
|
||||
|
||||
for (J = Q[0]->Next;J != Q[0];J = J->Next)
|
||||
{
|
||||
MJobGetStartPriority(J,0,&tmpD,0,NULL);
|
||||
MJobGetStartPriority(J,0,&tmpD,0,NULL,NULL);
|
||||
|
||||
J->StartPriority = (unsigned long)tmpD;
|
||||
|
||||
|
@ -5211,6 +5211,8 @@ int UIDiagnosePriority(
|
||||
int JobCount;
|
||||
|
||||
double tmpD;
|
||||
char *BPtr;
|
||||
int BSpace;
|
||||
|
||||
mjob_t *J;
|
||||
|
||||
@ -5220,15 +5222,14 @@ int UIDiagnosePriority(
|
||||
FName,
|
||||
(P != NULL) ? P->Name : "NULL");
|
||||
|
||||
Buffer[0] = '\0';
|
||||
|
||||
sprintf(Buffer,"%sdiagnosing job priority information (partition: %s)\n\n",
|
||||
Buffer,
|
||||
MUSNInit(&BPtr,&BSpace,Buffer,(int)*BufSize);
|
||||
|
||||
MUSNPrintF(&BPtr, &BSpace, "diagnosing job priority information (partition: %s)\n\n",
|
||||
P->Name);
|
||||
|
||||
/* initialize priority statistics */
|
||||
|
||||
MJobGetStartPriority(NULL,P->Index,NULL,1,Buffer);
|
||||
MJobGetStartPriority(NULL,P->Index,NULL,1,&BPtr,&BSpace);
|
||||
|
||||
JobCount = 0;
|
||||
|
||||
@ -5242,7 +5243,7 @@ int UIDiagnosePriority(
|
||||
DBG(5,fUI) DPrint("INFO: diagnosing priority for job '%s'\n",
|
||||
J->Name);
|
||||
|
||||
MJobGetStartPriority(J,P->Index,&tmpD,0,Buffer);
|
||||
MJobGetStartPriority(J,P->Index,&tmpD,0,&BPtr,&BSpace);
|
||||
|
||||
J->StartPriority = (long)tmpD;
|
||||
|
||||
@ -5251,7 +5252,7 @@ int UIDiagnosePriority(
|
||||
|
||||
if (JobCount > 0)
|
||||
{
|
||||
MJobGetStartPriority(NULL,P->Index,NULL,2,Buffer);
|
||||
MJobGetStartPriority(NULL,P->Index,NULL,2,&BPtr,&BSpace);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user