top(1): fix a buffer overflow copying states to display while they were incremented
- fix an AddressSanitizer error Submitted by: devnexen@gmail.com Reviewed by: eadler Approved by: gnn (mentor) Differential Revision: https://reviews.freebsd.org/D16183
This commit is contained in:
parent
9977c7b512
commit
08092a9b8f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=336756
@ -420,6 +420,7 @@ i_cpustates(int *states)
|
|||||||
int value;
|
int value;
|
||||||
const char * const *names;
|
const char * const *names;
|
||||||
const char *thisname;
|
const char *thisname;
|
||||||
|
int *hstates = states;
|
||||||
int cpu;
|
int cpu;
|
||||||
|
|
||||||
for (cpu = 0; cpu < num_cpus; cpu++) {
|
for (cpu = 0; cpu < num_cpus; cpu++) {
|
||||||
@ -453,6 +454,7 @@ for (cpu = 0; cpu < num_cpus; cpu++) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy over values into "last" array */
|
/* copy over values into "last" array */
|
||||||
|
states = hstates;
|
||||||
memcpy(lcpustates, states, num_cpustates * sizeof(int) * num_cpus);
|
memcpy(lcpustates, states, num_cpustates * sizeof(int) * num_cpus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,6 +464,7 @@ u_cpustates(int *states)
|
|||||||
int value;
|
int value;
|
||||||
const char * const *names;
|
const char * const *names;
|
||||||
const char *thisname;
|
const char *thisname;
|
||||||
|
int *hstates = states;
|
||||||
int *lp;
|
int *lp;
|
||||||
int *colp;
|
int *colp;
|
||||||
int cpu;
|
int cpu;
|
||||||
@ -504,6 +507,8 @@ for (cpu = 0; cpu < num_cpus; cpu++) {
|
|||||||
colp++;
|
colp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
states = hstates;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user