Skip to content

Commit

Permalink
Fixed reinvite null ref bug and updated webrtc projecct wtih vuln pac…
Browse files Browse the repository at this point in the history
…kages. (#1234)
  • Loading branch information
sipsorcery authored Nov 19, 2024
1 parent 6245311 commit bbf0867
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/SIPExamples/UserAgentClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static void Main(string[] args)
bool isCallHungup = false;
bool hasCallFailed = false;

Log = AddConsoleLogger(LogEventLevel.Verbose);
Log = AddConsoleLogger(LogEventLevel.Debug);

SIPURI callUri = SIPURI.ParseSIPURI(DEFAULT_DESTINATION_SIP_URI);
if (args?.Length > 0)
Expand Down
9 changes: 5 additions & 4 deletions examples/WebRTCExamples/WebRTCAspNetMvc/WebRTCAspNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions examples/WebRTCExamples/WebRTCDaemon/WebRTCDaemon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.1.2" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
Expand Down
20 changes: 16 additions & 4 deletions src/app/SIPUserAgents/SIPUserAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,19 +1007,31 @@ private async Task DialogRequestReceivedAsync(SIPRequest sipRequest)

try
{
SDP offer = SDP.ParseSDPDescription(sipRequest.Body);
SDP offer = !string.IsNullOrWhiteSpace(sipRequest.Body) ? SDP.ParseSDPDescription(sipRequest.Body) : null;

if (sipRequest.Header.CallId == _oldCallID)
{
// A transfer is in progress and this re-INVITE belongs to the original call. More than likely
// the purpose of the request is to place us on hold. We'll respond with OK but not update any local state.
var answerSdp = MediaSession.CreateAnswer(null);
var okResponse = reInviteTransaction.GetOkResponse(SDP.SDP_MIME_CONTENTTYPE, answerSdp.ToString());
reInviteTransaction.SendFinalResponse(okResponse);

if (answerSdp != null)
{
var okResponse = reInviteTransaction.GetOkResponse(SDP.SDP_MIME_CONTENTTYPE, answerSdp.ToString());
reInviteTransaction.SendFinalResponse(okResponse);
}
else
{
logger.LogWarning("Unable to create an answer for the re-INVITE request.");
var notAcceptableResponse = SIPResponse.GetResponse(sipRequest, SIPResponseStatusCodesEnum.NotAcceptable, "Unable to create an answer.");
reInviteTransaction.SendFinalResponse(notAcceptableResponse);
}
}
else
{
var setRemoteResult = MediaSession.SetRemoteDescription(SdpType.offer, offer);
// TODO: We should accept an empty re-INVITE body and send a new offer in the response. The remote peer can then send
// back teh SDP answer in the ACK.
var setRemoteResult = offer != null ? MediaSession.SetRemoteDescription(SdpType.offer, offer) : SetDescriptionResultEnum.Error;

if (setRemoteResult != SetDescriptionResultEnum.OK)
{
Expand Down

0 comments on commit bbf0867

Please sign in to comment.