mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-12-03 19:51:33 +00:00
Reject audio packets with no payload
It causes our Opus header validation to access uninitialized memory.
This commit is contained in:
1 parent
2b45ee9f64
commit
18922a1b32
1 file changed
+11
-1
+11
-1
@@ -175,11 +175,11 @@ static void decodeInputData(PQUEUED_AUDIO_PACKET packet) {
|
|||||||
|
|
||||||
lastSeq = rtp->sequenceNumber;
|
lastSeq = rtp->sequenceNumber;
|
||||||
|
|
||||||
|
int dataLength = packet->header.size - sizeof(*rtp);
|
||||||
if (AudioEncryptionEnabled) {
|
if (AudioEncryptionEnabled) {
|
||||||
// We must have room for the AES padding which may be written to the buffer
|
// We must have room for the AES padding which may be written to the buffer
|
||||||
unsigned char decryptedOpusData[ROUND_TO_PKCS7_PADDED_LEN(MAX_PACKET_SIZE)];
|
unsigned char decryptedOpusData[ROUND_TO_PKCS7_PADDED_LEN(MAX_PACKET_SIZE)];
|
||||||
unsigned char iv[16] = { 0 };
|
unsigned char iv[16] = { 0 };
|
||||||
int dataLength = packet->header.size - sizeof(*rtp);
|
|
||||||
|
|
||||||
LC_ASSERT(dataLength <= MAX_PACKET_SIZE);
|
LC_ASSERT(dataLength <= MAX_PACKET_SIZE);
|
||||||
|
|
||||||
@@ -200,6 +200,11 @@ static void decodeInputData(PQUEUED_AUDIO_PACKET packet) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dataLength == 0) {
|
||||||
|
LC_ASSERT_VT(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef LC_DEBUG
|
#ifdef LC_DEBUG
|
||||||
if (opusHeaderByte == INVALID_OPUS_HEADER) {
|
if (opusHeaderByte == INVALID_OPUS_HEADER) {
|
||||||
opusHeaderByte = decryptedOpusData[0];
|
opusHeaderByte = decryptedOpusData[0];
|
||||||
@@ -218,6 +223,11 @@ static void decodeInputData(PQUEUED_AUDIO_PACKET packet) {
|
|||||||
AudioCallbacks.decodeAndPlaySample((char*)decryptedOpusData, dataLength);
|
AudioCallbacks.decodeAndPlaySample((char*)decryptedOpusData, dataLength);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (dataLength == 0) {
|
||||||
|
LC_ASSERT_VT(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef LC_DEBUG
|
#ifdef LC_DEBUG
|
||||||
if (opusHeaderByte == INVALID_OPUS_HEADER) {
|
if (opusHeaderByte == INVALID_OPUS_HEADER) {
|
||||||
opusHeaderByte = ((uint8_t*)(rtp + 1))[0];
|
opusHeaderByte = ((uint8_t*)(rtp + 1))[0];
|
||||||
|
|||||||
Reference in new issue
Block a user