Skip to content
Snippets Groups Projects
Commit 8be88951 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

sipvoiplink: check find result before substr

Change-Id: Icca68a88a43b351b0bc5822888703ba774ee0138
parent fa708fe1
No related branches found
No related tags found
No related merge requests found
...@@ -227,14 +227,13 @@ transaction_request_cb(pjsip_rx_data* rdata) ...@@ -227,14 +227,13 @@ transaction_request_cb(pjsip_rx_data* rdata)
if (request.find("NOTIFY") != std::string_view::npos) { if (request.find("NOTIFY") != std::string_view::npos) {
if (body and body->data) { if (body and body->data) {
std::string_view body_view(static_cast<char*>(body->data), body->len);
auto pos = body_view.find("Voice-Message: ");
if (pos != std::string_view::npos) {
int newCount {0}; int newCount {0};
int oldCount {0}; int oldCount {0};
int urgentCount {0}; int urgentCount {0};
std::string sp(body_view.substr(pos));
std::string sp(static_cast<char*>(body->data), body->len);
auto pos = sp.find("Voice-Message: ");
sp = sp.substr(pos);
int ret = sscanf(sp.c_str(), int ret = sscanf(sp.c_str(),
"Voice-Message: %d/%d (%d/", "Voice-Message: %d/%d (%d/",
&newCount, &newCount,
...@@ -249,6 +248,7 @@ transaction_request_cb(pjsip_rx_data* rdata) ...@@ -249,6 +248,7 @@ transaction_request_cb(pjsip_rx_data* rdata)
oldCount, oldCount,
urgentCount); urgentCount);
} }
}
} else if (request.find("MESSAGE") != std::string_view::npos) { } else if (request.find("MESSAGE") != std::string_view::npos) {
// Reply 200 immediately (RFC 3428, ch. 7) // Reply 200 immediately (RFC 3428, ch. 7)
try_respond_stateless(endpt_, rdata, PJSIP_SC_OK, nullptr, nullptr, nullptr); try_respond_stateless(endpt_, rdata, PJSIP_SC_OK, nullptr, nullptr, nullptr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment