Closed lenerd closed 7 years ago
This function template
template<class T> T Get(int pos, int len) { T val = 0; GetBits((BYTE*) &val, pos, len); return val; }
is vulnerable to a buffer overflow on the stack. If len is larger than the size of T in bits, GetBits will overflow the local variable.
len
T
GetBits
This happens for example in the test cases with 191 bits. The template is instantiated as Get<uint64_t>(...) here:
Get<uint64_t>(...)
tmpret64 = vRcvX[k].Get<uint64_t>(i * m_nBitLength, m_nBitLength);
Thanks for pointing this out. I added assertions to CBitVector class that check for length boundary and changed the test output to binary.
This function template
is vulnerable to a buffer overflow on the stack. If
len
is larger than the size ofT
in bits,GetBits
will overflow the local variable.This happens for example in the test cases with 191 bits. The template is instantiated as
Get<uint64_t>(...)
here: