1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Silence security alert warning about possible infinite loop

As some have noticed, a security alert has been complaining about a for loop in
our TB code for quite some now. Though it was never a real issue, so not of high
importance.

A few lines earlier the symlen vector is resized
`d->symlen.resize(number<uint16_t, LittleEndian>(data));` while this code seems
odd at first, it resizes the array to at most (2 << 16) - 1 elements, basically
making the infinite loop issue impossible to occur.

closes https://github.com/official-stockfish/Stockfish/pull/4953

No functional change
This commit is contained in:
Disservin 2024-01-01 02:19:23 +01:00
parent 154abb337e
commit a25f48a236

View file

@ -1074,7 +1074,7 @@ uint8_t* set_sizes(PairsData* d, uint8_t* data) {
// See https://web.archive.org/web/20201106232444/http://www.larsson.dogma.net/dcc99.pdf // See https://web.archive.org/web/20201106232444/http://www.larsson.dogma.net/dcc99.pdf
std::vector<bool> visited(d->symlen.size()); std::vector<bool> visited(d->symlen.size());
for (Sym sym = 0; sym < d->symlen.size(); ++sym) for (std::size_t sym = 0; sym < d->symlen.size(); ++sym)
if (!visited[sym]) if (!visited[sym])
d->symlen[sym] = set_symlen(d, sym, visited); d->symlen[sym] = set_symlen(d, sym, visited);