Channels: fix off-by-one bound in decryptForHash (#11046)
decryptForHash accepted chIndex == getNumChannels() before reading getHash(chIndex), which indexes one past hashes[MAX_NUM_CHANNELS]. Use >= so an out-of-range index is rejected before the array read.
This commit is contained in:
co-authored by
GitHub
parent
8147970957
commit
cfecef5376
@@ -516,7 +516,7 @@ bool Channels::hasDefaultChannel()
|
||||
*/
|
||||
bool Channels::decryptForHash(ChannelIndex chIndex, ChannelHash channelHash)
|
||||
{
|
||||
if (chIndex > getNumChannels() || getHash(chIndex) != channelHash) {
|
||||
if (chIndex >= getNumChannels() || getHash(chIndex) != channelHash) {
|
||||
// LOG_DEBUG("Skip channel %d (hash %x) due to invalid hash/index, want=%x", chIndex, getHash(chIndex),
|
||||
// channelHash);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user