diff options
author | teravus | 2012-12-31 23:04:28 -0500 |
---|---|---|
committer | teravus | 2012-12-31 23:04:28 -0500 |
commit | 2805ec64662494d680925c6034e59b823e051a9d (patch) | |
tree | ba2294dab3ced1b10962d373d29fb6011b55735c | |
parent | * This finishes the implementation of AgentCachedTexture. Requires the XBak... (diff) | |
download | opensim-SC-2805ec64662494d680925c6034e59b823e051a9d.zip opensim-SC-2805ec64662494d680925c6034e59b823e051a9d.tar.gz opensim-SC-2805ec64662494d680925c6034e59b823e051a9d.tar.bz2 opensim-SC-2805ec64662494d680925c6034e59b823e051a9d.tar.xz |
* Fixed a bug that replayed old cached appearance when changing outfits
* Added suser(bad client) DOS protection by limiting the max cacheitems to the maximum sane amount.
* Prevents potential numerous loops from running amok and index errors if the client purposely provides bad cache info.
* If the XBakes service wasn't running, the SetAvatarAppearance routine would crash when contacting the XBakes service even though it was in a Try/Catch for the appropriate error type. It only properly error handles with the type Exception :(. (commented on that because it's unusual)
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs | 123 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 34 |
2 files changed, 111 insertions, 46 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index 6778ba5..6bed95f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs | |||
@@ -119,13 +119,20 @@ namespace OpenSim.Region.ClientStack.Linden | |||
119 | 119 | ||
120 | private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) | 120 | private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) |
121 | { | 121 | { |
122 | int maxCacheitemsLoop = cacheItems.Length; | ||
123 | if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES) | ||
124 | { | ||
125 | maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES; | ||
126 | m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES); | ||
127 | } | ||
128 | |||
122 | m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | 129 | m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); |
123 | if (cacheItems.Length > 0) | 130 | if (cacheItems.Length > 0) |
124 | { | 131 | { |
125 | m_log.Info("[Cacheitems]: " + cacheItems.Length); | 132 | m_log.Debug("[Cacheitems]: " + cacheItems.Length); |
126 | for (int iter = 0; iter < cacheItems.Length; iter++) | 133 | for (int iter = 0; iter < maxCacheitemsLoop; iter++) |
127 | { | 134 | { |
128 | m_log.Info("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + | 135 | m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + |
129 | cacheItems[iter].TextureID); | 136 | cacheItems[iter].TextureID); |
130 | } | 137 | } |
131 | 138 | ||
@@ -133,65 +140,99 @@ namespace OpenSim.Region.ClientStack.Linden | |||
133 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) | 140 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) |
134 | { | 141 | { |
135 | 142 | ||
136 | WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; | 143 | WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; |
137 | if (existingitems == null) | 144 | if (existingitems == null) |
145 | { | ||
146 | if (m_BakedTextureModule != null) | ||
138 | { | 147 | { |
139 | if (m_BakedTextureModule != null) | 148 | WearableCacheItem[] savedcache = null; |
149 | try | ||
140 | { | 150 | { |
141 | WearableCacheItem[] savedcache = null; | 151 | if (p.Appearance.WearableCacheItemsDirty) |
142 | try | ||
143 | { | ||
144 | if (p.Appearance.WearableCacheItemsDirty) | ||
145 | { | ||
146 | savedcache = m_BakedTextureModule.Get(p.UUID); | ||
147 | p.Appearance.WearableCacheItems = savedcache; | ||
148 | p.Appearance.WearableCacheItemsDirty = false; | ||
149 | } | ||
150 | |||
151 | } | ||
152 | catch (InvalidOperationException) | ||
153 | { | 152 | { |
153 | savedcache = m_BakedTextureModule.Get(p.UUID); | ||
154 | p.Appearance.WearableCacheItems = savedcache; | ||
155 | p.Appearance.WearableCacheItemsDirty = false; | ||
154 | } | 156 | } |
155 | 157 | ||
156 | if (savedcache != null) | ||
157 | existingitems = savedcache; | ||
158 | } | 158 | } |
159 | /* | ||
160 | * The following Catch types DO NOT WORK with m_BakedTextureModule.Get | ||
161 | * it jumps to the General Packet Exception Handler if you don't catch Exception! | ||
162 | * | ||
163 | catch (System.Net.Sockets.SocketException) | ||
164 | { | ||
165 | cacheItems = null; | ||
166 | } | ||
167 | catch (WebException) | ||
168 | { | ||
169 | cacheItems = null; | ||
170 | } | ||
171 | catch (InvalidOperationException) | ||
172 | { | ||
173 | cacheItems = null; | ||
174 | } */ | ||
175 | catch (Exception) | ||
176 | { | ||
177 | // The service logs a sufficient error message. | ||
178 | } | ||
179 | |||
180 | |||
181 | if (savedcache != null) | ||
182 | existingitems = savedcache; | ||
159 | } | 183 | } |
160 | // Existing items null means it's a fully new appearance | 184 | } |
161 | if (existingitems == null) | 185 | // Existing items null means it's a fully new appearance |
162 | { | 186 | if (existingitems == null) |
187 | { | ||
163 | 188 | ||
164 | for (int iter = 0; iter < cacheItems.Length; iter++) | 189 | for (int i = 0; i < maxCacheitemsLoop; i++) |
190 | { | ||
191 | if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) | ||
165 | { | 192 | { |
166 | 193 | cacheItems[i].TextureID = | |
167 | cacheItems[iter].TextureID = textureEntry.FaceTextures[cacheItems[iter].TextureIndex].TextureID; | 194 | textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID; |
168 | if (m_scene.AssetService != null) | 195 | if (m_scene.AssetService != null) |
169 | cacheItems[iter].TextureAsset = m_scene.AssetService.GetCached(cacheItems[iter].TextureID.ToString()); | 196 | cacheItems[i].TextureAsset = |
170 | 197 | m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); | |
171 | 198 | } | |
199 | else | ||
200 | { | ||
201 | m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length); | ||
172 | } | 202 | } |
203 | |||
204 | |||
173 | } | 205 | } |
174 | else | 206 | } |
175 | 207 | else | |
176 | 208 | ||
209 | |||
210 | { | ||
211 | // for each uploaded baked texture | ||
212 | for (int i = 0; i < maxCacheitemsLoop; i++) | ||
177 | { | 213 | { |
178 | // for each uploaded baked texture | 214 | if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) |
179 | for (int i = 0; i < cacheItems.Length; i++) | ||
180 | { | 215 | { |
181 | cacheItems[i].TextureID = | 216 | cacheItems[i].TextureID = |
182 | textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID; | 217 | textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID; |
183 | } | 218 | } |
184 | 219 | else | |
185 | for (int i = 0; i < cacheItems.Length; i++) | ||
186 | { | 220 | { |
187 | if (cacheItems[i].TextureAsset == null) | 221 | m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length); |
188 | { | ||
189 | cacheItems[i].TextureAsset = m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); | ||
190 | } | ||
191 | } | 222 | } |
192 | } | 223 | } |
193 | 224 | ||
194 | 225 | for (int i = 0; i < maxCacheitemsLoop; i++) | |
226 | { | ||
227 | if (cacheItems[i].TextureAsset == null) | ||
228 | { | ||
229 | cacheItems[i].TextureAsset = | ||
230 | m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); | ||
231 | } | ||
232 | } | ||
233 | } | ||
234 | |||
235 | |||
195 | 236 | ||
196 | p.Appearance.WearableCacheItems = cacheItems; | 237 | p.Appearance.WearableCacheItems = cacheItems; |
197 | 238 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 9e39699..d46adb8 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -11727,6 +11727,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11727 | 11727 | ||
11728 | IAssetService cache = m_scene.AssetService; | 11728 | IAssetService cache = m_scene.AssetService; |
11729 | IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | 11729 | IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); |
11730 | //bakedTextureModule = null; | ||
11731 | int maxWearablesLoop = cachedtex.WearableData.Length; | ||
11732 | if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES) | ||
11733 | maxWearablesLoop = AvatarWearable.MAX_WEARABLES; | ||
11734 | |||
11730 | if (bakedTextureModule != null && cache != null) | 11735 | if (bakedTextureModule != null && cache != null) |
11731 | { | 11736 | { |
11732 | // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid | 11737 | // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid |
@@ -11742,10 +11747,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11742 | p.Appearance.WearableCacheItems = cacheItems; | 11747 | p.Appearance.WearableCacheItems = cacheItems; |
11743 | p.Appearance.WearableCacheItemsDirty = false; | 11748 | p.Appearance.WearableCacheItemsDirty = false; |
11744 | } | 11749 | } |
11750 | |||
11751 | /* | ||
11752 | * The following Catch types DO NOT WORK, it jumps to the General Packet Exception Handler if you don't catch Exception! | ||
11753 | * | ||
11754 | catch (System.Net.Sockets.SocketException) | ||
11755 | { | ||
11756 | cacheItems = null; | ||
11757 | } | ||
11758 | catch (WebException) | ||
11759 | { | ||
11760 | cacheItems = null; | ||
11761 | } | ||
11745 | catch (InvalidOperationException) | 11762 | catch (InvalidOperationException) |
11746 | { | 11763 | { |
11747 | cacheItems = null; | 11764 | cacheItems = null; |
11765 | } */ | ||
11766 | catch (Exception) | ||
11767 | { | ||
11768 | cacheItems = null; | ||
11748 | } | 11769 | } |
11770 | |||
11749 | } | 11771 | } |
11750 | else if (p.Appearance.WearableCacheItems != null) | 11772 | else if (p.Appearance.WearableCacheItems != null) |
11751 | { | 11773 | { |
@@ -11766,10 +11788,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11766 | 11788 | ||
11767 | } | 11789 | } |
11768 | } | 11790 | } |
11791 | |||
11769 | if (cacheItems != null) | 11792 | if (cacheItems != null) |
11770 | { | 11793 | { |
11771 | 11794 | ||
11772 | for (int i = 0; i < cachedtex.WearableData.Length; i++) | 11795 | for (int i = 0; i < maxWearablesLoop; i++) |
11773 | { | 11796 | { |
11774 | WearableCacheItem item = | 11797 | WearableCacheItem item = |
11775 | WearableCacheItem.SearchTextureIndex(cachedtex.WearableData[i].TextureIndex,cacheItems); | 11798 | WearableCacheItem.SearchTextureIndex(cachedtex.WearableData[i].TextureIndex,cacheItems); |
@@ -11777,8 +11800,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11777 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | 11800 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); |
11778 | cachedresp.WearableData[i].TextureIndex= cachedtex.WearableData[i].TextureIndex; | 11801 | cachedresp.WearableData[i].TextureIndex= cachedtex.WearableData[i].TextureIndex; |
11779 | cachedresp.WearableData[i].HostName = new byte[0]; | 11802 | cachedresp.WearableData[i].HostName = new byte[0]; |
11780 | if (item != null) | 11803 | if (item != null && cachedtex.WearableData[i].ID == item.CacheId) |
11781 | { | 11804 | { |
11805 | |||
11782 | cachedresp.WearableData[i].TextureID = item.TextureID; | 11806 | cachedresp.WearableData[i].TextureID = item.TextureID; |
11783 | } | 11807 | } |
11784 | else | 11808 | else |
@@ -11789,7 +11813,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11789 | } | 11813 | } |
11790 | else | 11814 | else |
11791 | { | 11815 | { |
11792 | for (int i = 0; i < cachedtex.WearableData.Length; i++) | 11816 | for (int i = 0; i < maxWearablesLoop; i++) |
11793 | { | 11817 | { |
11794 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | 11818 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); |
11795 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; | 11819 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; |
@@ -11803,7 +11827,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11803 | { | 11827 | { |
11804 | if (cache == null) | 11828 | if (cache == null) |
11805 | { | 11829 | { |
11806 | for (int i = 0; i < cachedtex.WearableData.Length; i++) | 11830 | for (int i = 0; i < maxWearablesLoop; i++) |
11807 | { | 11831 | { |
11808 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | 11832 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); |
11809 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; | 11833 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; |
@@ -11814,7 +11838,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11814 | } | 11838 | } |
11815 | else | 11839 | else |
11816 | { | 11840 | { |
11817 | for (int i = 0; i < cachedtex.WearableData.Length; i++) | 11841 | for (int i = 0; i < maxWearablesLoop; i++) |
11818 | { | 11842 | { |
11819 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | 11843 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); |
11820 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; | 11844 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; |