MT#59962 AmSdp::parse(): always check return value

When using that, the return value must always
be checked, because the parsing itself can indeed fail.

Fixes such things as:

** CID 583412:       Error handling issues  (CHECKED_RETURN)
/core/AmB2BSession.cpp: 340           in AmB2BSession::acceptPendingInvite(AmSipRequest *, const AmMimeBody *)()
_____________________________________________________________________________________________
*** CID 583412:         Error handling issues  (CHECKED_RETURN)
/core/AmB2BSession.cpp: 340             in AmB2BSession::acceptPendingInvite(AmSipRequest *, const AmMimeBody *)()
334         return;
335       }
336
337       /* port must reflect actual port in SDP offer coming in */
338       if (sdp) {
339         AmSdp fake_sdp;
>>>     CID 583412:         Error handling issues  (CHECKED_RETURN)
>>>     Calling "parse" without checking return value (as is done elsewhere 12 out of 15 times).
340         fake_sdp.parse((const char *)sdp->getPayload());
341         desired_port = getMediaPort(fake_sdp);
342       }
343
344       if (desired_port) {
345         ILOG_DLG(L_DBG, "Desired port for fake 200OK is '%d'\n", desired_port);

Change-Id: I7bd177a624ebe2df2629863eb31f97f99bd921bb
mr13.5
Donat Zenichev 6 months ago
parent e005af4e12
commit 50b7bc2459

@ -1869,7 +1869,13 @@ void SBCCallLeg::createHoldRequest(AmSdp &sdp)
// version number in every SDP passing through?)
AmMimeBody *s = dlg->established_body.hasContentType(SIP_APPLICATION_SDP);
if (s) sdp.parse((const char*)s->getPayload());
if (s) {
if (sdp.parse((const char*)s->getPayload()))
{
ILOG_DLG(L_WARN, "Failed to parse SDP.\n");
return;
}
}
if (sdp.media.empty()) {
// established SDP is not valid! generate complete fake

@ -291,7 +291,11 @@ void AmB2BSession::addFakeSDPbasedOnPort(const AmMimeBody *src_sdp, AmMimeBody &
/* create fake AmSdp from AmMimeBody */
AmSdp fake_sdp;
AmMimeBody fake_mimebody;
fake_sdp.parse((const char *)src_sdp->getPayload());
if (fake_sdp.parse((const char *)src_sdp->getPayload()))
{
ILOG_DLG(L_WARN, "Failed to parse SDP.\n");
return;
}
for (auto it = fake_sdp.media.begin(); it != fake_sdp.media.end(); ++it)
{
@ -337,8 +341,13 @@ void AmB2BSession::acceptPendingInvite(AmSipRequest *invite, const AmMimeBody *s
/* port must reflect actual port in SDP offer coming in */
if (sdp) {
AmSdp fake_sdp;
fake_sdp.parse((const char *)sdp->getPayload());
desired_port = getMediaPort(fake_sdp);
if (fake_sdp.parse((const char *)sdp->getPayload()))
{
ILOG_DLG(L_WARN, "Failed to parse SDP.\n");
}
else {
desired_port = getMediaPort(fake_sdp);
}
}
if (desired_port) {

Loading…
Cancel
Save