Merge branch 'master' into ch341

This commit is contained in:
Jonathan Bennett 2024-12-04 21:55:28 -06:00 committed by GitHub
commit ccb8074f28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 3 deletions

View File

@ -178,12 +178,11 @@ CryptoKey Channels::getKey(ChannelIndex chIndex)
{ {
meshtastic_Channel &ch = getByIndex(chIndex); meshtastic_Channel &ch = getByIndex(chIndex);
const meshtastic_ChannelSettings &channelSettings = ch.settings; const meshtastic_ChannelSettings &channelSettings = ch.settings;
assert(ch.has_settings);
CryptoKey k; CryptoKey k;
memset(k.bytes, 0, sizeof(k.bytes)); // In case the user provided a short key, we want to pad the rest with zeros memset(k.bytes, 0, sizeof(k.bytes)); // In case the user provided a short key, we want to pad the rest with zeros
if (ch.role == meshtastic_Channel_Role_DISABLED) { if (!ch.has_settings || ch.role == meshtastic_Channel_Role_DISABLED) {
k.length = -1; // invalid k.length = -1; // invalid
} else { } else {
memcpy(k.bytes, channelSettings.psk.bytes, channelSettings.psk.size); memcpy(k.bytes, channelSettings.psk.bytes, channelSettings.psk.size);

View File

@ -36,7 +36,8 @@ bool FloodingRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
if (isRepeated) { if (isRepeated) {
LOG_DEBUG("Repeated reliable tx"); LOG_DEBUG("Repeated reliable tx");
if (!perhapsRebroadcast(p) && isToUs(p) && p->want_ack) { if (!perhapsRebroadcast(p) && isToUs(p) && p->want_ack) {
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, p->channel, 0); // FIXME - channel index should be used, but the packet is still encrypted here
sendAckNak(meshtastic_Routing_Error_NONE, getFrom(p), p->id, 0, 0);
} }
} }

View File

@ -271,6 +271,7 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
auto encodeResult = perhapsEncode(p); auto encodeResult = perhapsEncode(p);
if (encodeResult != meshtastic_Routing_Error_NONE) { if (encodeResult != meshtastic_Routing_Error_NONE) {
packetPool.release(p_decoded); packetPool.release(p_decoded);
p->channel = 0; // Reset the channel to 0, so we don't use the failing hash again
abortSendAndNak(encodeResult, p); abortSendAndNak(encodeResult, p);
return encodeResult; // FIXME - this isn't a valid ErrorCode return encodeResult; // FIXME - this isn't a valid ErrorCode
} }