Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential buffer overflow issue #263

Merged
merged 1 commit into from
Aug 16, 2023
Merged

Fix potential buffer overflow issue #263

merged 1 commit into from
Aug 16, 2023

Conversation

Nailik
Copy link
Contributor

@Nailik Nailik commented Aug 2, 2023

I found this issue while implementing a small resampler based on this project.

Description
AudioRendererand AudioOverlayFilteruse:

val estimatedTargetSampleCount = ceil(sourceSampleCount * samplingRatio).toInt()
 val targetBufferCapacity = estimatedTargetSampleCount * channelCount * BYTES_PER_SAMPLE

to calculate the size of the target buffer.
In case this estimation is too small (happens on big differences in samplerate) this results in 2 issues.

Issue
processAudioFrame in audio-processor.cpp doesn't know about the size, resulting in memory access vialoation.

Fix
Drop audio when target buffer capacity is reached.

Issue
targetFrame.buffer.limit(targetBufferSize) throws an IllegalArgumentException.

Fix
Take min min(targetBufferSize, targetFrame.buffer.capacity())

Copy link
Contributor

@izzytwosheds izzytwosheds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix. Thank you!

@Nailik
Copy link
Contributor Author

Nailik commented Aug 16, 2023

@izzytwosheds i fixed a small issue you could review again.

@izzytwosheds izzytwosheds merged commit b10ebca into linkedin:main Aug 16, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants