Skip to content

Commit b3c87ef

Browse files
authored
prevent buffer overflow in metadata
1 parent 53ca299 commit b3c87ef

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Audio.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*
44
* Created on: Oct 26.2018
55
*
6-
* Version 2.0.5h
7-
* Updated on: Aug 11.2022
6+
* Version 2.0.5g
7+
* Updated on: Aug 12.2022
88
* Author: Wolle (schreibfaul1)
99
*
1010
*/
@@ -2363,6 +2363,7 @@ bool Audio::playChunk() {
23632363
return true;
23642364
}
23652365
log_e("BitsPer Sample must be 8 or 16!");
2366+
m_validSamples = 0;
23662367
stopSong();
23672368
return false;
23682369
}
@@ -3733,7 +3734,7 @@ bool Audio:: initializeDecoder(){
37333734
InBuff.changeMaxBlockSize(m_frameSizeWav);
37343735
break;
37353736
case CODEC_OGG:
3736-
m_codec = CODEC_OGG; log_e("!");
3737+
m_codec = CODEC_OGG;
37373738
AUDIO_INFO("ogg not supported");
37383739
goto exit;
37393740
break;
@@ -3774,7 +3775,7 @@ uint16_t Audio::readMetadata(uint16_t maxBytes, bool first) {
37743775
}
37753776
if(!metalen) {m_metacount = m_metaint; return res;}
37763777

3777-
uint16_t a = _client->readBytes(&chbuf[pos_ml], min(metalen, (uint16_t)(maxBytes -1)));
3778+
uint16_t a = _client->readBytes(&chbuf[pos_ml], min((uint16_t)(metalen - pos_ml), (uint16_t)(maxBytes -1)));
37783779
res += a;
37793780
pos_ml += a;
37803781
if(pos_ml == metalen) {
@@ -4078,7 +4079,7 @@ int Audio::sendBytes(uint8_t* data, size_t len) {
40784079
case CODEC_M4A: ret = AACDecode(data, &bytesLeft, m_outBuff); break;
40794080
case CODEC_FLAC: ret = FLACDecode(data, &bytesLeft, m_outBuff); break;
40804081
case CODEC_OGG_FLAC: ret = FLACDecode(data, &bytesLeft, m_outBuff); break; // FLAC webstream wrapped in OGG
4081-
default: {log_e("no valid codec found"); stopSong();}
4082+
default: {log_e("no valid codec found codec = %d", m_codec); stopSong();}
40824083
}
40834084

40844085
bytesDecoded = len - bytesLeft;

src/Audio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Audio.h
33
*
44
* Created on: Oct 28,2018
5-
* Updated on: Aug 11,2022
5+
* Updated on: Aug 12,2022
66
* Author: Wolle (schreibfaul1)
77
*/
88

0 commit comments

Comments
 (0)