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:
Thomas Göttgens
2026-07-17 08:15:19 -05:00
committed by GitHub
co-authored by GitHub
parent 8147970957
commit cfecef5376
+1 -1
View File
@@ -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;