diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2020-09-23 22:44:17 +0300 | 
|---|---|---|
| committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2020-09-23 22:44:17 +0300 | 
| commit | bf8cc6b2f7d0563a61dcc45b7feaf4fffacbfbe1 (patch) | |
| tree | 3730c622467c105be876eefba30c2a435b424264 /indra/newview | |
| parent | 8b410efa4f6eccb689f6adb901ec3eec8cdd8541 (diff) | |
SL-13986 Validate buffer size to avoid SIGBUS crash on sscanf
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/lllandmarklist.cpp | 63 | 
1 files changed, 33 insertions, 30 deletions
| diff --git a/indra/newview/lllandmarklist.cpp b/indra/newview/lllandmarklist.cpp index c58540914e..a790e513a2 100644 --- a/indra/newview/lllandmarklist.cpp +++ b/indra/newview/lllandmarklist.cpp @@ -109,36 +109,39 @@ void LLLandmarkList::processGetAssetReply(  		LLVFile file(vfs, uuid, type);  		S32 file_length = file.getSize(); -		std::vector<char> buffer(file_length + 1); -		file.read( (U8*)&buffer[0], file_length); -		buffer[ file_length ] = 0; - -		LLLandmark* landmark = LLLandmark::constructFromString(&buffer[0]); -		if (landmark) -		{ -			gLandmarkList.mList[ uuid ] = landmark; -			gLandmarkList.mRequestedList.erase(uuid); -			 -			LLVector3d pos; -			if(!landmark->getGlobalPos(pos)) -			{ -				LLUUID region_id; -				if(landmark->getRegionID(region_id)) -				{ -					LLLandmark::requestRegionHandle( -						gMessageSystem, -						gAgent.getRegionHost(), -						region_id, -						boost::bind(&LLLandmarkList::onRegionHandle, &gLandmarkList, uuid)); -				} - -				// the callback will be called when we get the region handle. -			} -			else -			{ -				gLandmarkList.makeCallbacks(uuid); -			} -		} +        if (file_length > 0) +        { +            std::vector<char> buffer(file_length + 1); +            file.read((U8*)&buffer[0], file_length); +            buffer[file_length] = 0; + +            LLLandmark* landmark = LLLandmark::constructFromString(&buffer[0], buffer.size()); +            if (landmark) +            { +                gLandmarkList.mList[uuid] = landmark; +                gLandmarkList.mRequestedList.erase(uuid); + +                LLVector3d pos; +                if (!landmark->getGlobalPos(pos)) +                { +                    LLUUID region_id; +                    if (landmark->getRegionID(region_id)) +                    { +                        LLLandmark::requestRegionHandle( +                            gMessageSystem, +                            gAgent.getRegionHost(), +                            region_id, +                            boost::bind(&LLLandmarkList::onRegionHandle, &gLandmarkList, uuid)); +                    } + +                    // the callback will be called when we get the region handle. +                } +                else +                { +                    gLandmarkList.makeCallbacks(uuid); +                } +            } +        }  	}  	else  	{ | 
