[Asterisk-code-review] codec.c: Defensively check the returned samples. (asterisk[master])
Joshua Colp
asteriskteam at digium.com
Fri Oct 27 09:19:11 CDT 2017
Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/6923 )
Change subject: codec.c: Defensively check the returned samples.
......................................................................
codec.c: Defensively check the returned samples.
Earlier versions of the codec_opus samples_count callback can return
negative error values on undecodable frames. This resulted in a divide by
zero exception.
* Added a defensive check in ast_codec_samples_count() for a "negative"
samples count return value. Log the event and set the count to zero.
ASTERISK-27194
Change-Id: Icf69350307ecbbc80a3d74de46af9bd80ea17819
---
M main/codec.c
1 file changed, 5 insertions(+), 0 deletions(-)
Approvals:
Benjamin Keith Ford: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
diff --git a/main/codec.c b/main/codec.c
index 7797147..5b262f6 100644
--- a/main/codec.c
+++ b/main/codec.c
@@ -406,6 +406,11 @@
if (codec->samples_count) {
samples = codec->samples_count(frame);
+ if ((int) samples < 0) {
+ ast_log(LOG_WARNING, "Codec %s returned invalid number of samples.\n",
+ ast_format_get_name(frame->subclass.format));
+ samples = 0;
+ }
} else {
ast_log(LOG_WARNING, "Unable to calculate samples for codec %s\n",
ast_format_get_name(frame->subclass.format));
--
To view, visit https://gerrit.asterisk.org/6923
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Icf69350307ecbbc80a3d74de46af9bd80ea17819
Gerrit-Change-Number: 6923
Gerrit-PatchSet: 2
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171027/cb4a42c3/attachment.html>
More information about the asterisk-code-review
mailing list