diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2013-02-01 09:13:31 -0500 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2013-02-01 09:13:31 -0500 |
commit | 235f77b8c6194d7e6ab55a73dda4a31d19948323 (patch) | |
tree | ff8d7a6d5a788b3e194bdcbe9c1a5c65001d482a /indra/newview/llvoavatar.cpp | |
parent | 54a1c9510c7bf9e672d2600fa359db5c05752fb3 (diff) |
SH-3800 WIP - reject appearance messages with contradictory appearance version info
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rwxr-xr-x | indra/newview/llvoavatar.cpp | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 5b4f31f91a..537bb70579 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -6645,11 +6645,13 @@ struct LLAppearanceMessageContents { LLAppearanceMessageContents(): mAppearanceVersion(-1), + mParamAppearanceVersion(-1), mCOFVersion(LLViewerInventoryCategory::VERSION_UNKNOWN) { } LLTEContents mTEContents; S32 mAppearanceVersion; + S32 mParamAppearanceVersion; S32 mCOFVersion; // For future use: //U32 appearance_flags = 0; @@ -6730,7 +6732,6 @@ void LLVOAvatar::parseAppearanceMessage(LLMessageSystem* mesgsys, LLAppearanceMe } LLVisualParam* appearance_version_param = getVisualParam(11000); - S32 param_appearance_version = -1; if (appearance_version_param) { std::vector<LLVisualParam*>::iterator it = std::find(contents.mParams.begin(), contents.mParams.end(),appearance_version_param); @@ -6738,28 +6739,38 @@ void LLVOAvatar::parseAppearanceMessage(LLMessageSystem* mesgsys, LLAppearanceMe { S32 index = it - contents.mParams.begin(); llinfos << "index: " << index << llendl; - param_appearance_version = llround(contents.mParamWeights[index]); - LL_DEBUGS("Avatar") << "appversion req by appearance_version param: " << contents.mAppearanceVersion << llendl; + contents.mParamAppearanceVersion = llround(contents.mParamWeights[index]); + LL_DEBUGS("Avatar") << "appversion req by appearance_version param: " << contents.mParamAppearanceVersion << llendl; } } +} + +bool resolve_appearance_version(const LLAppearanceMessageContents& contents, S32& appearance_version) +{ if ((contents.mAppearanceVersion) >= 0 && - (param_appearance_version >= 0) && - (contents.mAppearanceVersion != param_appearance_version)) + (contents.mParamAppearanceVersion >= 0) && + (contents.mAppearanceVersion != contents.mParamAppearanceVersion)) { llwarns << "inconsistent appearance_version settings - field: " << - contents.mAppearanceVersion << ", param: " << param_appearance_version << llendl; + contents.mAppearanceVersion << ", param: " << contents.mParamAppearanceVersion << llendl; + return false; + } + if (contents.mParamAppearanceVersion >= 0) // use visual param if available. + { + appearance_version = contents.mParamAppearanceVersion; + LL_DEBUGS("Avatar") << "appversion set by appearance_version param: " << appearance_version << llendl; } - if (contents.mAppearanceVersion < 0 && - param_appearance_version >= 0) // not set explicitly, try to get from visual param. + if (contents.mAppearanceVersion >= 0) { - contents.mAppearanceVersion = param_appearance_version; - LL_DEBUGS("Avatar") << "appversion set by appearance_version param: " << contents.mAppearanceVersion << llendl; + appearance_version = contents.mAppearanceVersion; + LL_DEBUGS("Avatar") << "appversion set by appearance_version field: " << appearance_version << llendl; } if (contents.mAppearanceVersion < 0) // still not set, go with 0. { - contents.mAppearanceVersion = 0; - LL_DEBUGS("Avatar") << "appversion set by default: " << contents.mAppearanceVersion << llendl; + appearance_version = 0; + LL_DEBUGS("Avatar") << "appversion set by default: " << appearance_version << llendl; } + return true; } //----------------------------------------------------------------------------- @@ -6776,13 +6787,21 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) return; } - ESex old_sex = getSex(); LLAppearanceMessageContents contents; parseAppearanceMessage(mesgsys, contents); + if (enable_verbose_dumps) + { + dumpAppearanceMsgParams(dump_prefix + "appearance_msg", contents.mParamWeights, contents.mTEContents); + } - U8 appearance_version = contents.mAppearanceVersion; + S32 appearance_version; + if (!resolve_appearance_version(contents, appearance_version)) + { + llwarns << "bad appearance version info, discarding" << llendl; + return; + } S32 this_update_cof_version = contents.mCOFVersion; S32 last_update_request_cof_version = LLAppearanceMgr::instance().mLastUpdateRequestCOFVersion; @@ -6891,13 +6910,6 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) } } } - if (enable_verbose_dumps) - { - dumpAppearanceMsgParams(dump_prefix + "appearance_msg", contents.mParamWeights, contents.mTEContents); - } - - //if (enable_verbose_dumps) { dumpArchetypeXML(dump_prefix + "process_post_set_weights"); } - const S32 expected_tweakable_count = getVisualParamCountInGroup(VISUAL_PARAM_GROUP_TWEAKABLE); // don't worry about VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT if (num_params != expected_tweakable_count) { |