From 9522a0b7c16414fce2103cf58bfdd63aaf0cb01b Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 3 Nov 2022 14:58:32 -0400 Subject: DRTVWR-575: Fix llcommon assumptions that size_t fits in 4 bytes. It's a little distressing how often we have historically coded S32 or U32 to pass a length or index. There are more such assumptions in other viewer subdirectories, but this is a start. --- indra/llcommon/llsdserialize.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/llcommon/llsdserialize.h') diff --git a/indra/llcommon/llsdserialize.h b/indra/llcommon/llsdserialize.h index d6079fd9fa..86d34cde9a 100644 --- a/indra/llcommon/llsdserialize.h +++ b/indra/llcommon/llsdserialize.h @@ -77,7 +77,7 @@ public: * @return Returns the number of LLSD objects parsed into * data. Returns PARSE_FAILURE (-1) on parse failure. */ - S32 parse(std::istream& istr, LLSD& data, S32 max_bytes, S32 max_depth = -1); + S32 parse(std::istream& istr, LLSD& data, size_t max_bytes, S32 max_depth = -1); /** Like parse(), but uses a different call (istream.getline()) to read by lines * This API is better suited for XML, where the parse cannot tell @@ -205,7 +205,7 @@ protected: /** * @brief The maximum number of bytes left to be parsed. */ - mutable S32 mMaxBytesLeft; + mutable size_t mMaxBytesLeft; /** * @brief Use line-based reading to get text @@ -756,7 +756,7 @@ public: * @param max_bytes the maximum number of bytes to parse * @return Returns true if the stream appears to contain valid data */ - static bool deserialize(LLSD& sd, std::istream& str, S32 max_bytes); + static bool deserialize(LLSD& sd, std::istream& str, size_t max_bytes); /* * Notation Methods @@ -778,12 +778,12 @@ public: LLSDFormatter::EFormatterOptions(LLSDFormatter::OPTIONS_PRETTY | LLSDFormatter::OPTIONS_PRETTY_BINARY)); } - static S32 fromNotation(LLSD& sd, std::istream& str, S32 max_bytes) + static S32 fromNotation(LLSD& sd, std::istream& str, size_t max_bytes) { LLPointer p = new LLSDNotationParser; return p->parse(str, sd, max_bytes); } - static LLSD fromNotation(std::istream& str, S32 max_bytes) + static LLSD fromNotation(std::istream& str, size_t max_bytes) { LLPointer p = new LLSDNotationParser; LLSD sd; @@ -834,12 +834,12 @@ public: LLPointer f = new LLSDBinaryFormatter; return f->format(sd, str, LLSDFormatter::OPTIONS_NONE); } - static S32 fromBinary(LLSD& sd, std::istream& str, S32 max_bytes, S32 max_depth = -1) + static S32 fromBinary(LLSD& sd, std::istream& str, size_t max_bytes, S32 max_depth = -1) { LLPointer p = new LLSDBinaryParser; return p->parse(str, sd, max_bytes, max_depth); } - static LLSD fromBinary(std::istream& str, S32 max_bytes, S32 max_depth = -1) + static LLSD fromBinary(std::istream& str, size_t max_bytes, S32 max_depth = -1) { LLPointer p = new LLSDBinaryParser; LLSD sd; -- cgit v1.2.3 From 73aced620fce59d98373cec6e830315bb6781546 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 6 Dec 2022 13:59:06 -0500 Subject: DRTVWR-575: Use llssize (signed size_t) for max_bytes parameters. Since LLSDSerialize::SIZE_UNLIMITED is negative, passing that through unsigned size_t parameters could result in peculiar behavior. --- indra/llcommon/llsdserialize.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/llcommon/llsdserialize.h') diff --git a/indra/llcommon/llsdserialize.h b/indra/llcommon/llsdserialize.h index 86d34cde9a..ddcd795e8a 100644 --- a/indra/llcommon/llsdserialize.h +++ b/indra/llcommon/llsdserialize.h @@ -77,7 +77,7 @@ public: * @return Returns the number of LLSD objects parsed into * data. Returns PARSE_FAILURE (-1) on parse failure. */ - S32 parse(std::istream& istr, LLSD& data, size_t max_bytes, S32 max_depth = -1); + S32 parse(std::istream& istr, LLSD& data, llssize max_bytes, S32 max_depth = -1); /** Like parse(), but uses a different call (istream.getline()) to read by lines * This API is better suited for XML, where the parse cannot tell @@ -205,7 +205,7 @@ protected: /** * @brief The maximum number of bytes left to be parsed. */ - mutable size_t mMaxBytesLeft; + mutable llssize mMaxBytesLeft; /** * @brief Use line-based reading to get text @@ -756,7 +756,7 @@ public: * @param max_bytes the maximum number of bytes to parse * @return Returns true if the stream appears to contain valid data */ - static bool deserialize(LLSD& sd, std::istream& str, size_t max_bytes); + static bool deserialize(LLSD& sd, std::istream& str, llssize max_bytes); /* * Notation Methods @@ -778,12 +778,12 @@ public: LLSDFormatter::EFormatterOptions(LLSDFormatter::OPTIONS_PRETTY | LLSDFormatter::OPTIONS_PRETTY_BINARY)); } - static S32 fromNotation(LLSD& sd, std::istream& str, size_t max_bytes) + static S32 fromNotation(LLSD& sd, std::istream& str, llssize max_bytes) { LLPointer p = new LLSDNotationParser; return p->parse(str, sd, max_bytes); } - static LLSD fromNotation(std::istream& str, size_t max_bytes) + static LLSD fromNotation(std::istream& str, llssize max_bytes) { LLPointer p = new LLSDNotationParser; LLSD sd; @@ -834,12 +834,12 @@ public: LLPointer f = new LLSDBinaryFormatter; return f->format(sd, str, LLSDFormatter::OPTIONS_NONE); } - static S32 fromBinary(LLSD& sd, std::istream& str, size_t max_bytes, S32 max_depth = -1) + static S32 fromBinary(LLSD& sd, std::istream& str, llssize max_bytes, S32 max_depth = -1) { LLPointer p = new LLSDBinaryParser; return p->parse(str, sd, max_bytes, max_depth); } - static LLSD fromBinary(std::istream& str, size_t max_bytes, S32 max_depth = -1) + static LLSD fromBinary(std::istream& str, llssize max_bytes, S32 max_depth = -1) { LLPointer p = new LLSDBinaryParser; LLSD sd; -- cgit v1.2.3 From db1d757aebc3dd23e542f7cd4f468dbcd97edcb7 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 6 Dec 2022 14:40:11 -0500 Subject: DRTVWR-575: Update a few more int lengths in llsdserialize.{h,cpp}. --- indra/llcommon/llsdserialize.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/llsdserialize.h') diff --git a/indra/llcommon/llsdserialize.h b/indra/llcommon/llsdserialize.h index ddcd795e8a..bd5ef668c0 100644 --- a/indra/llcommon/llsdserialize.h +++ b/indra/llcommon/llsdserialize.h @@ -194,7 +194,7 @@ protected: * Conceptually const since it only modifies mutable members. * @param bytes The number of bytes read. */ - void account(S32 bytes) const; + void account(llssize bytes) const; protected: /** @@ -336,7 +336,7 @@ private: class Impl; Impl& impl; - void parsePart(const char* buf, int len); + void parsePart(const char* buf, llssize len); friend class LLSDSerialize; }; @@ -867,5 +867,5 @@ public: LL_COMMON_API std::string zip_llsd(LLSD& data); -LL_COMMON_API U8* unzip_llsdNavMesh( bool& valid, unsigned int& outsize,std::istream& is, S32 size); +LL_COMMON_API U8* unzip_llsdNavMesh( bool& valid, size_t& outsize,std::istream& is, S32 size); #endif // LL_LLSDSERIALIZE_H -- cgit v1.2.3