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)
|
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),
|
// LOG_DEBUG("Skip channel %d (hash %x) due to invalid hash/index, want=%x", chIndex, getHash(chIndex),
|
||||||
// channelHash);
|
// channelHash);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user