netem: fix out of bounds access in maketable

The maketable program used to generate one of the configuration
files at build time for netem would access past the end of the array
for one input value. This is a bug inherited from original NISTnet.
Just fold the value, like other code there.

This is not a runtime error security problem.
It only impacts the build process if the build machine
had extra hardening enabled.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Stephen Hemminger 2017-04-12 10:10:44 -07:00
parent 5551ed44d3
commit 2d3af1675d
1 changed files with 2 additions and 0 deletions

View File

@ -149,6 +149,8 @@ inverttable(int *table, int inversesize, int tablesize, int cumulative)
inversevalue = (int)rint(findex*TABLEFACTOR);
if (inversevalue <= MINSHORT) inversevalue = MINSHORT+1;
if (inversevalue > MAXSHORT) inversevalue = MAXSHORT;
if (inverseindex >= inversesize) inverseindex = inversesize- 1;
inverse[inverseindex] = inversevalue;
}
return inverse;