[Asterisk-code-review] chan ooh323: Fix infinite loop on read second part of H.225 ... (asterisk[14])
Joshua Colp
asteriskteam at digium.com
Mon Nov 7 09:23:46 CST 2016
Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/4295 )
Change subject: chan_ooh323: Fix infinite loop on read second part of H.225 packet
......................................................................
chan_ooh323: Fix infinite loop on read second part of H.225 packet
Fix logic on read second part of H.225 packet. There was infinite loop on
wrong connections due to read before poll.
Change-Id: I42b4bf75c46e4a5c5df5c5ca1f0bd74b8944e7ff
---
M addons/ooh323c/src/oochannels.c
1 file changed, 20 insertions(+), 7 deletions(-)
Approvals:
Mark Michelson: Looks good to me, but someone else must approve
Anonymous Coward #1000019: Verified
Joshua Colp: Looks good to me, approved
diff --git a/addons/ooh323c/src/oochannels.c b/addons/ooh323c/src/oochannels.c
index 76f8422..a09470d 100644
--- a/addons/ooh323c/src/oochannels.c
+++ b/addons/ooh323c/src/oochannels.c
@@ -1061,11 +1061,6 @@
while(total < len)
{
struct pollfd pfds;
- recvLen = ooSocketRecv (call->pH225Channel->sock, message1, len-total);
- memcpy(message+total, message1, recvLen);
- total = total + recvLen;
-
- if(total == len) break; /* Complete message is received */
pfds.fd = call->pH225Channel->sock;
pfds.events = POLLIN;
@@ -1085,8 +1080,9 @@
}
return OO_FAILED;
}
- /* If remaining part of the message is not received in 3 seconds
- exit */
+
+ /* exit If remaining part of the message is not received in 3 seconds */
+
if(!ooPDRead(&pfds, 1, call->pH225Channel->sock))
{
OOTRACEERR3("Error: Incomplete H.2250 message received - clearing "
@@ -1099,6 +1095,23 @@
}
return OO_FAILED;
}
+
+ recvLen = ooSocketRecv (call->pH225Channel->sock, message1, len-total);
+ if (recvLen == 0) {
+ OOTRACEERR3("Error in read while receiving H.2250 message - "
+ "clearing call (%s, %s)\n", call->callType,
+ call->callToken);
+ ooFreeQ931Message(pctxt, pmsg);
+ if(call->callState < OO_CALL_CLEAR)
+ {
+ call->callEndReason = OO_REASON_TRANSPORTFAILURE;
+ call->callState = OO_CALL_CLEAR;
+ }
+ return OO_FAILED;
+ }
+ memcpy(message+total, message1, recvLen);
+ total = total + recvLen;
+
}
OOTRACEDBGC3("Received Q.931 message: (%s, %s)\n",
--
To view, visit https://gerrit.asterisk.org/4295
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I42b4bf75c46e4a5c5df5c5ca1f0bd74b8944e7ff
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Alexander Anikin <may213 at yandex.ru>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
More information about the asterisk-code-review
mailing list