Crash fix for empty media URL.

Apparently LLViewerMediaImpl::navigateInternal could be called with
an empty url. That lead to a curl request with an empty url, which
failed because that leads to an empty 'service' string, which is
not allowed.

Patched the code to ignore empty media urls and hardened AICurl
to deal with any remaining cases.
This commit is contained in:
Aleric Inglewood
2013-09-22 23:25:40 +02:00
parent 992d8e960c
commit 12d3873aa7
3 changed files with 22 additions and 1 deletions

View File

@@ -116,6 +116,15 @@ void AICurlEasyRequestStateMachine::multiplex_impl(state_type run_state)
{
set_state(AICurlEasyRequestStateMachine_waitAdded);
idle(); // Wait till AICurlEasyRequestStateMachine::added_to_multi_handle() is called.
// This is a work around for the case that this request had a bad url, in order to avoid a crash later on.
bool empty_url = AICurlEasyRequest_rat(*mCurlEasyRequest)->getLowercaseServicename().empty();
if (empty_url)
{
abort();
break;
}
// Only AFTER going idle, add request to curl thread; this is needed because calls to set_state() are
// ignored when the statemachine is not idle, and theoretically the callbacks could be called
// immediately after this call.

View File

@@ -214,7 +214,7 @@ std::string AIPerService::extract_canonical_servicename(std::string const& url)
}
++p;
}
// Strip of any trailing ":80".
// Strip off any trailing ":80".
if (p - 3 == port_colon && p[-1] == '0' && p[-2] == '8')
{
return servicename.substr(0, p - hostname - 3);

View File

@@ -2595,6 +2595,12 @@ void LLViewerMediaImpl::unload()
//////////////////////////////////////////////////////////////////////////////////////////
void LLViewerMediaImpl::navigateTo(const std::string& url, const std::string& mime_type, bool rediscover_type, bool server_request)
{
if (url.empty())
{
llwarns << "Calling LLViewerMediaImpl::navigateTo with empty url" << llendl;
return;
}
cancelMimeTypeProbe();
if(mMediaURL != url)
@@ -2639,6 +2645,12 @@ void LLViewerMediaImpl::navigateInternal()
// Helpful to have media urls in log file. Shouldn't be spammy.
llinfos << "media id= " << mTextureId << " url=" << mMediaURL << " mime_type=" << mMimeType << llendl;
if (mMediaURL.empty())
{
llwarns << "Calling LLViewerMediaImpl::navigateInternal() with empty mMediaURL" << llendl;
return;
}
if(mNavigateSuspended)
{
llwarns << "Deferring navigate." << llendl;