From bf8cc6b2f7d0563a61dcc45b7feaf4fffacbfbe1 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 23 Sep 2020 22:44:17 +0300 Subject: SL-13986 Validate buffer size to avoid SIGBUS crash on sscanf --- indra/newview/lllandmarklist.cpp | 63 +++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'indra/newview') 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 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 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 { -- cgit v1.2.3