diff options
author | Jacek Antonelli | 2010-02-18 19:19:12 -0600 |
---|---|---|
committer | Jacek Antonelli | 2010-02-18 19:19:12 -0600 |
commit | 76937222933d5830a9e1de80a86072c31039bc12 (patch) | |
tree | 5f59369af66088b379bbcdcaccf0fcd8fd751607 /linden | |
parent | SNOW-488: Malformed animation crash. (diff) | |
download | meta-impy-76937222933d5830a9e1de80a86072c31039bc12.zip meta-impy-76937222933d5830a9e1de80a86072c31039bc12.tar.gz meta-impy-76937222933d5830a9e1de80a86072c31039bc12.tar.bz2 meta-impy-76937222933d5830a9e1de80a86072c31039bc12.tar.xz |
SNOW-492: LLDataPacker::unpackstring() is unsafe.
Patch by Robin Cornelius.
Diffstat (limited to 'linden')
-rw-r--r-- | linden/indra/llcharacter/llkeyframemotion.cpp | 4 | ||||
-rw-r--r-- | linden/indra/llmessage/lldatapacker.cpp | 23 |
2 files changed, 20 insertions, 7 deletions
diff --git a/linden/indra/llcharacter/llkeyframemotion.cpp b/linden/indra/llcharacter/llkeyframemotion.cpp index 46dee09..e6ef767 100644 --- a/linden/indra/llcharacter/llkeyframemotion.cpp +++ b/linden/indra/llcharacter/llkeyframemotion.cpp | |||
@@ -1355,8 +1355,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) | |||
1355 | } | 1355 | } |
1356 | else | 1356 | else |
1357 | { | 1357 | { |
1358 | llwarns << "joint not found: " << joint_name << llendl; | 1358 | llwarns << "joint not found: " << llendl; |
1359 | //return FALSE; | 1359 | return FALSE; |
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | joint_motion->mJointName = joint_name; | 1362 | joint_motion->mJointName = joint_name; |
diff --git a/linden/indra/llmessage/lldatapacker.cpp b/linden/indra/llmessage/lldatapacker.cpp index 1cdb475..e4243a5 100644 --- a/linden/indra/llmessage/lldatapacker.cpp +++ b/linden/indra/llmessage/lldatapacker.cpp | |||
@@ -186,18 +186,31 @@ BOOL LLDataPackerBinaryBuffer::packString(const std::string& value, const char * | |||
186 | return success; | 186 | return success; |
187 | } | 187 | } |
188 | 188 | ||
189 | |||
190 | BOOL LLDataPackerBinaryBuffer::unpackString(std::string& value, const char *name) | 189 | BOOL LLDataPackerBinaryBuffer::unpackString(std::string& value, const char *name) |
191 | { | 190 | { |
192 | BOOL success = TRUE; | 191 | //Sanitise the string before attemping ANY buffer operations |
193 | S32 length = (S32)strlen((char *)mCurBufferp) + 1; /*Flawfinder: ignore*/ | 192 | U8 * pos; |
193 | S32 length=0; | ||
194 | for(pos=mCurBufferp;pos<(mBufferp+mBufferSize);pos++) | ||
195 | { | ||
196 | length++; | ||
197 | if((*pos)==0) | ||
198 | break; | ||
199 | } | ||
194 | 200 | ||
195 | success &= verifyLength(length, name); | 201 | if(length>=mBufferSize) |
202 | { | ||
203 | llwarns << "Unpack string failed, null termination not found"<<llendl; | ||
204 | return false; | ||
205 | } | ||
206 | |||
207 | if(!verifyLength(length, name)) | ||
208 | return false; | ||
196 | 209 | ||
197 | value = std::string((char*)mCurBufferp); // We already assume NULL termination calling strlen() | 210 | value = std::string((char*)mCurBufferp); // We already assume NULL termination calling strlen() |
198 | 211 | ||
199 | mCurBufferp += length; | 212 | mCurBufferp += length; |
200 | return success; | 213 | return true; |
201 | } | 214 | } |
202 | 215 | ||
203 | BOOL LLDataPackerBinaryBuffer::packBinaryData(const U8 *value, S32 size, const char *name) | 216 | BOOL LLDataPackerBinaryBuffer::packBinaryData(const U8 *value, S32 size, const char *name) |