diff options
| author | simon <simon@lindenlab.com> | 2023-05-12 17:29:41 +0100 | 
|---|---|---|
| committer | simon <simon@lindenlab.com> | 2023-05-24 00:25:57 +0100 | 
| commit | 55460b49585ceea5d6388204c7f3bd74ed4f4827 (patch) | |
| tree | 82abff5f99357a11eb5579cd076d4cb44c9c1c99 /indra | |
| parent | f366853f22ec6914471d7b265adf53736f080527 (diff) | |
SL-19711 - viewer can't parse environments.  Fixed max parsing bug
(cherry picked from commit eb0516b9940f200b32349d611f38f1ccee48005d)
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llcommon/llsdserialize.cpp | 20 | ||||
| -rw-r--r-- | indra/newview/llsettingsvo.cpp | 4 | 
2 files changed, 15 insertions, 9 deletions
| diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp index e7482b601d..56cc141f0d 100644 --- a/indra/llcommon/llsdserialize.cpp +++ b/indra/llcommon/llsdserialize.cpp @@ -125,14 +125,20 @@ bool LLSDSerialize::deserialize(LLSD& sd, std::istream& str, llssize max_bytes)  	char hdr_buf[MAX_HDR_LEN + 1] = ""; /* Flawfinder: ignore */  	bool fail_if_not_legacy = false; -	/* -	 * Get the first line before anything. Don't read more than max_bytes: -	 * this get() overload reads no more than (count-1) bytes into the -	 * specified buffer. In the usual case when max_bytes exceeds -	 * sizeof(hdr_buf), get() will read no more than sizeof(hdr_buf)-2. -	 */ -	str.get(hdr_buf, llmin(max_bytes+1, sizeof(hdr_buf)-1), '\n'); +    /* +     * Get the first line before anything. Don't read more than max_bytes: +     * this get() overload reads no more than (count-1) bytes into the +     * specified buffer. In the usual case when max_bytes exceeds +     * sizeof(hdr_buf), get() will read no more than sizeof(hdr_buf)-2. +     */ +    llssize max_hdr_read = MAX_HDR_LEN; +	if (max_bytes != LLSDSerialize::SIZE_UNLIMITED) +	{ +        max_hdr_read = llmin(max_bytes + 1, max_hdr_read); +	} +    str.get(hdr_buf, max_hdr_read, '\n');  	auto inbuf = str.gcount(); +  	// https://en.cppreference.com/w/cpp/io/basic_istream/get  	// When the get() above sees the specified delimiter '\n', it stops there  	// without pulling it from the stream. If it turns out that the stream diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index b1eed81476..f5212a3026 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -312,7 +312,7 @@ void LLSettingsVOBase::onAssetDownloadComplete(const LLUUID &asset_id, S32 statu          std::stringstream llsdstream(buffer);          LLSD llsdsettings; -        if (LLSDSerialize::deserialize(llsdsettings, llsdstream, -1)) +        if (LLSDSerialize::deserialize(llsdsettings, llsdstream, LLSDSerialize::SIZE_UNLIMITED))          {              settings = createFromLLSD(llsdsettings);          } @@ -379,7 +379,7 @@ LLSettingsBase::ptr_t LLSettingsVOBase::importFile(const std::string &filename)              return LLSettingsBase::ptr_t();          } -        if (!LLSDSerialize::deserialize(settings, file, -1)) +        if (!LLSDSerialize::deserialize(settings, file, LLSDSerialize::SIZE_UNLIMITED))          {              LL_WARNS("SETTINGS") << "Unable to deserialize settings from '" << filename << "'" << LL_ENDL;              return LLSettingsBase::ptr_t(); | 
