top: prevent buffer overflow potential in all routines
Whereas an original patch (referenced below) addressed some symptoms related to manually edited config files, this solution deals with root causes. And it goes much beyond any single top field by protecting all of top's fields. Henceforth, a duplicated field is not allowed. Reference(s): . original qualys patch 0114-top-Prevent-buffer-overflow-in-calibrate_fields.patch Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
ffee26c370
commit
085351a0ee
@ -3246,7 +3246,7 @@ static const char *config_file (FILE *fp, const char *name, float *delay) {
|
|||||||
*delay = (float)tmp_whole + (float)tmp_fract / 1000;
|
*delay = (float)tmp_whole + (float)tmp_fract / 1000;
|
||||||
|
|
||||||
for (i = 0 ; i < GROUPSMAX; i++) {
|
for (i = 0 ; i < GROUPSMAX; i++) {
|
||||||
int x;
|
int n, x;
|
||||||
WIN_t *w = &Winstk[i];
|
WIN_t *w = &Winstk[i];
|
||||||
p = fmtmk(N_fmt(RC_bad_entry_fmt), i+1, name);
|
p = fmtmk(N_fmt(RC_bad_entry_fmt), i+1, name);
|
||||||
|
|
||||||
@ -3258,6 +3258,11 @@ static const char *config_file (FILE *fp, const char *name, float *delay) {
|
|||||||
too bad fscanf is not as flexible with his format string as snprintf
|
too bad fscanf is not as flexible with his format string as snprintf
|
||||||
error Hey, fix the above fscanf 'PFLAGSSIZ' dependency !
|
error Hey, fix the above fscanf 'PFLAGSSIZ' dependency !
|
||||||
#endif
|
#endif
|
||||||
|
// ensure there's been no manual alteration of fieldscur
|
||||||
|
for (n = 0 ; n < EU_MAXPFLGS; n++) {
|
||||||
|
if (strchr(w->rc.fieldscur, w->rc.fieldscur[n]) != strrchr(w->rc.fieldscur, w->rc.fieldscur[n]))
|
||||||
|
return p;
|
||||||
|
}
|
||||||
// be tolerant of missing release 3.3.10 graph modes additions
|
// be tolerant of missing release 3.3.10 graph modes additions
|
||||||
if (3 > fscanf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d, graph_cpus=%d, graph_mems=%d\n"
|
if (3 > fscanf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d, graph_cpus=%d, graph_mems=%d\n"
|
||||||
, &w->rc.winflags, &w->rc.sortindx, &w->rc.maxtasks, &w->rc.graph_cpus, &w->rc.graph_mems))
|
, &w->rc.winflags, &w->rc.sortindx, &w->rc.maxtasks, &w->rc.graph_cpus, &w->rc.graph_mems))
|
||||||
|
Loading…
Reference in New Issue
Block a user