summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2022-12-06 13:59:06 -0500
committerNat Goodspeed <nat@lindenlab.com>2022-12-06 13:59:06 -0500
commit73aced620fce59d98373cec6e830315bb6781546 (patch)
tree2077828fb3aa31c6b643657ba12aa16f19506d34 /indra/llcommon
parent8f6ffd489df9d6346e04070ad8209f2432ef3416 (diff)
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.
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llsdserialize.cpp14
-rw-r--r--indra/llcommon/llsdserialize.h14
2 files changed, 14 insertions, 14 deletions
diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp
index b720e6adb6..08b3e52597 100644
--- a/indra/llcommon/llsdserialize.cpp
+++ b/indra/llcommon/llsdserialize.cpp
@@ -99,7 +99,7 @@ void LLSDSerialize::serialize(const LLSD& sd, std::ostream& str, ELLSD_Serialize
}
// static
-bool LLSDSerialize::deserialize(LLSD& sd, std::istream& str, size_t max_bytes)
+bool LLSDSerialize::deserialize(LLSD& sd, std::istream& str, llssize max_bytes)
{
LLPointer<LLSDParser> p = NULL;
char hdr_buf[MAX_HDR_LEN + 1] = ""; /* Flawfinder: ignore */
@@ -252,7 +252,7 @@ F64 ll_ntohd(F64 netdouble)
* @return Returns number of bytes read off of the stream. Returns
* PARSE_FAILURE (-1) on failure.
*/
-int deserialize_string(std::istream& istr, std::string& value, size_t max_bytes);
+int deserialize_string(std::istream& istr, std::string& value, llssize max_bytes);
/**
* @brief Parse a delimited string.
@@ -280,7 +280,7 @@ int deserialize_string_delim(std::istream& istr, std::string& value, char d);
int deserialize_string_raw(
std::istream& istr,
std::string& value,
- size_t max_bytes);
+ llssize max_bytes);
/**
* @brief helper method for dealing with the different notation boolean format.
@@ -329,7 +329,7 @@ LLSDParser::LLSDParser()
LLSDParser::~LLSDParser()
{ }
-S32 LLSDParser::parse(std::istream& istr, LLSD& data, size_t max_bytes, S32 max_depth)
+S32 LLSDParser::parse(std::istream& istr, LLSD& data, llssize max_bytes, S32 max_depth)
{
mCheckLimits = (LLSDSerialize::SIZE_UNLIMITED == max_bytes) ? false : true;
mMaxBytesLeft = max_bytes;
@@ -1592,7 +1592,7 @@ void LLSDBinaryFormatter::formatString(
/**
* local functions
*/
-int deserialize_string(std::istream& istr, std::string& value, size_t max_bytes)
+int deserialize_string(std::istream& istr, std::string& value, llssize max_bytes)
{
int c = istr.get();
if(istr.fail())
@@ -1728,7 +1728,7 @@ int deserialize_string_delim(
int deserialize_string_raw(
std::istream& istr,
std::string& value,
- size_t max_bytes)
+ llssize max_bytes)
{
int count = 0;
const S32 BUF_LEN = 20;
@@ -2173,7 +2173,7 @@ std::string zip_llsd(LLSD& data)
LLUZipHelper::EZipRresult LLUZipHelper::unzip_llsd(LLSD& data, std::istream& is, S32 size)
{
U8* result = NULL;
- size_t cur_size = 0;
+ llssize cur_size = 0;
z_stream strm;
const U32 CHUNK = 65536;
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<LLSDNotationParser> 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<LLSDNotationParser> p = new LLSDNotationParser;
LLSD sd;
@@ -834,12 +834,12 @@ public:
LLPointer<LLSDBinaryFormatter> 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<LLSDBinaryParser> 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<LLSDBinaryParser> p = new LLSDBinaryParser;
LLSD sd;