Skip to content

Commit bbf0867

Browse files
authored
Fixed reinvite null ref bug and updated webrtc projecct wtih vuln packages. (#1234)
1 parent 6245311 commit bbf0867

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

examples/SIPExamples/UserAgentClient/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void Main(string[] args)
5252
bool isCallHungup = false;
5353
bool hasCallFailed = false;
5454

55-
Log = AddConsoleLogger(LogEventLevel.Verbose);
55+
Log = AddConsoleLogger(LogEventLevel.Debug);
5656

5757
SIPURI callUri = SIPURI.ParseSIPURI(DEFAULT_DESTINATION_SIP_URI);
5858
if (args?.Length > 0)

examples/WebRTCExamples/WebRTCAspNetMvc/WebRTCAspNet.csproj

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
9-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
10-
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
11-
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
8+
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
9+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="9.0.0" />
10+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
11+
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
12+
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
1213
</ItemGroup>
1314

1415
<ItemGroup>

examples/WebRTCExamples/WebRTCDaemon/WebRTCDaemon.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
2424
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
2525
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
26+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
2627
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.1.2" />
2728
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
2829
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />

src/app/SIPUserAgents/SIPUserAgent.cs

+16-4
Original file line numberDiff line numberDiff line change
@@ -1007,19 +1007,31 @@ private async Task DialogRequestReceivedAsync(SIPRequest sipRequest)
10071007

10081008
try
10091009
{
1010-
SDP offer = SDP.ParseSDPDescription(sipRequest.Body);
1010+
SDP offer = !string.IsNullOrWhiteSpace(sipRequest.Body) ? SDP.ParseSDPDescription(sipRequest.Body) : null;
10111011

10121012
if (sipRequest.Header.CallId == _oldCallID)
10131013
{
10141014
// A transfer is in progress and this re-INVITE belongs to the original call. More than likely
10151015
// the purpose of the request is to place us on hold. We'll respond with OK but not update any local state.
10161016
var answerSdp = MediaSession.CreateAnswer(null);
1017-
var okResponse = reInviteTransaction.GetOkResponse(SDP.SDP_MIME_CONTENTTYPE, answerSdp.ToString());
1018-
reInviteTransaction.SendFinalResponse(okResponse);
1017+
1018+
if (answerSdp != null)
1019+
{
1020+
var okResponse = reInviteTransaction.GetOkResponse(SDP.SDP_MIME_CONTENTTYPE, answerSdp.ToString());
1021+
reInviteTransaction.SendFinalResponse(okResponse);
1022+
}
1023+
else
1024+
{
1025+
logger.LogWarning("Unable to create an answer for the re-INVITE request.");
1026+
var notAcceptableResponse = SIPResponse.GetResponse(sipRequest, SIPResponseStatusCodesEnum.NotAcceptable, "Unable to create an answer.");
1027+
reInviteTransaction.SendFinalResponse(notAcceptableResponse);
1028+
}
10191029
}
10201030
else
10211031
{
1022-
var setRemoteResult = MediaSession.SetRemoteDescription(SdpType.offer, offer);
1032+
// TODO: We should accept an empty re-INVITE body and send a new offer in the response. The remote peer can then send
1033+
// back teh SDP answer in the ACK.
1034+
var setRemoteResult = offer != null ? MediaSession.SetRemoteDescription(SdpType.offer, offer) : SetDescriptionResultEnum.Error;
10231035

10241036
if (setRemoteResult != SetDescriptionResultEnum.OK)
10251037
{

0 commit comments

Comments
 (0)