Skip to content
Snippets Groups Projects
Commit bbd071f3 authored by Andrey Kleshchev's avatar Andrey Kleshchev
Browse files

SL-14597 ensure that uris don't crash viewer

parent bee13995
No related branches found
No related tags found
No related merge requests found
...@@ -163,26 +163,37 @@ S32 LLUriParser::normalize() ...@@ -163,26 +163,37 @@ S32 LLUriParser::normalize()
mNormalizedTmp = mTmpScheme; mNormalizedTmp = mTmpScheme;
if (!mRes) if (!mRes)
{ {
mRes = uriNormalizeSyntaxExA(&mUri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST); // Uriparser is 3p software we can not directly fix.
// On winodws this probably requires SEH handling, but all
if (!mRes) // crashes so far were on MAC in scope of uriNormalizeSyntaxExA.
{ try
S32 chars_required; {
mRes = uriToStringCharsRequiredA(&mUri, &chars_required); mRes = uriNormalizeSyntaxExA(&mUri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST);
if (!mRes) if (!mRes)
{ {
chars_required++; S32 chars_required;
std::vector<char> label_buf(chars_required); mRes = uriToStringCharsRequiredA(&mUri, &chars_required);
mRes = uriToStringA(&label_buf[0], &mUri, chars_required, NULL);
if (!mRes)
if (!mRes) {
{ chars_required++;
mNormalizedUri = &label_buf[mTmpScheme ? 7 : 0]; std::vector<char> label_buf(chars_required);
mTmpScheme = false; mRes = uriToStringA(&label_buf[0], &mUri, chars_required, NULL);
}
} if (!mRes)
} {
mNormalizedUri = &label_buf[mTmpScheme ? 7 : 0];
mTmpScheme = false;
}
}
}
}
catch (...)
{
// At this point mNormalizedUri should contain http+unmodified input string.
LL_WARNS() << "Uriparser crashed processing: " << mNormalizedUri << LL_ENDL;
}
} }
if(mTmpScheme) if(mTmpScheme)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment