[Asterisk-code-review] res rtp asterisk.c: Fix off-nominal crash potential. (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Thu Jul 30 20:44:46 CDT 2015


Richard Mudgett has uploaded a new change for review.

  https://gerrit.asterisk.org/1007

Change subject: res_rtp_asterisk.c: Fix off-nominal crash potential.
......................................................................

res_rtp_asterisk.c: Fix off-nominal crash potential.

ASTERISK-25296
Reported by: Richard Mudgett

Change-Id: I08549fb7c3ab40a559f41a3940f3732a4059b55b
---
M res/res_rtp_asterisk.c
1 file changed, 5 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/07/1007/1

diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 5d206c1..00617e4 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -4504,6 +4504,10 @@
 	}
 
 	payload = ast_rtp_codecs_get_payload(ast_rtp_instance_get_codecs(instance), payloadtype);
+	if (!payload) {
+		/* Unknown payload type. */
+		return AST_LIST_FIRST(&frames) ? AST_LIST_FIRST(&frames) : &ast_null_frame;
+	}
 
 	/* If the payload is not actually an Asterisk one but a special one pass it off to the respective handler */
 	if (!payload->asterisk_format) {
@@ -4530,10 +4534,7 @@
 		/* Even if no frame was returned by one of the above methods,
 		 * we may have a frame to return in our frame list
 		 */
-		if (!AST_LIST_EMPTY(&frames)) {
-			return AST_LIST_FIRST(&frames);
-		}
-		return &ast_null_frame;
+		return AST_LIST_FIRST(&frames) ? AST_LIST_FIRST(&frames) : &ast_null_frame;
 	}
 
 	ao2_replace(rtp->lastrxformat, payload->format);

-- 
To view, visit https://gerrit.asterisk.org/1007
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I08549fb7c3ab40a559f41a3940f3732a4059b55b
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list