From eb8191164df76d29b24743c7092909e533ef415d Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@bred.dog>
Date: Thu, 8 Oct 2020 23:54:49 -0400
Subject: [PATCH] Replace snprintf with absl::SNPrintF for better platform
 portability

---
 indra/llcharacter/llkeyframemotion.cpp        | 11 ++--
 indra/llcharacter/llmultigesture.cpp          | 12 ++--
 indra/llcorehttp/_httpoprequest.cpp           | 15 ++---
 .../llcorehttp/examples/http_texture_load.cpp |  8 +--
 indra/llcorehttp/tests/test_httprequest.hpp   |  6 +-
 indra/llmessage/lldatapacker.cpp              | 66 +++++++++----------
 indra/llmessage/llinstantmessage.cpp          |  2 +-
 indra/llmessage/message.cpp                   |  4 +-
 indra/llprimitive/lldaeloader.cpp             |  2 +-
 indra/llprimitive/lltextureentry.cpp          |  6 +-
 indra/llrender/llgldbg.cpp                    |  6 +-
 indra/newview/llviewerassetstats.cpp          |  2 +-
 12 files changed, 65 insertions(+), 75 deletions(-)

diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp
index cf80be04d64..094e621d052 100644
--- a/indra/llcharacter/llkeyframemotion.cpp
+++ b/indra/llcharacter/llkeyframemotion.cpp
@@ -2058,7 +2058,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
 		success &= dp.packU8(shared_constraintp->mChainLength, "chain_length");
 		success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type");
 		char source_volume[16]; /* Flawfinder: ignore */
-		snprintf(source_volume, sizeof(source_volume), "%s",	/* Flawfinder: ignore */
+		absl::SNPrintF(source_volume, sizeof(source_volume), "%s",	/* Flawfinder: ignore */
 				 mCharacter->findCollisionVolume(shared_constraintp->mSourceConstraintVolume)->getName().c_str()); 
         
 		success &= dp.packBinaryDataFixed((U8*)source_volume, 16, "source_volume");
@@ -2066,11 +2066,11 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
 		char target_volume[16];	/* Flawfinder: ignore */
 		if (shared_constraintp->mConstraintTargetType == CONSTRAINT_TARGET_TYPE_GROUND)
 		{
-			snprintf(target_volume,sizeof(target_volume), "%s", "GROUND");	/* Flawfinder: ignore */
+			absl::SNPrintF(target_volume,sizeof(target_volume), "%s", "GROUND");	/* Flawfinder: ignore */
 		}
 		else
 		{
-			snprintf(target_volume, sizeof(target_volume),"%s", /* Flawfinder: ignore */
+			absl::SNPrintF(target_volume, sizeof(target_volume),"%s", /* Flawfinder: ignore */
 					 mCharacter->findCollisionVolume(shared_constraintp->mTargetConstraintVolume)->getName().c_str());	
 		}
 		success &= dp.packBinaryDataFixed((U8*)target_volume, 16, "target_volume");
@@ -2383,8 +2383,6 @@ void LLKeyframeDataCache::dumpDiagInfo()
 	// keep track of totals
 	U32 total_size = 0;
 
-	char buf[1024];		/* Flawfinder: ignore */
-
 	LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
 	LL_INFOS() << "       Global Motion Table (DEBUG only)" << LL_ENDL;
 	LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
@@ -2406,8 +2404,7 @@ void LLKeyframeDataCache::dumpDiagInfo()
 
 	LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
 	LL_INFOS() << "Motions\tTotal Size" << LL_ENDL;
-	snprintf(buf, sizeof(buf), "%d\t\t%d bytes", (S32)sKeyframeDataMap.size(), total_size );		/* Flawfinder: ignore */
-	LL_INFOS() << buf << LL_ENDL;
+	LL_INFOS() << absl::StreamFormat("%d\t\t%d bytes", (S32)sKeyframeDataMap.size(), total_size) << LL_ENDL;
 	LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
 }
 
diff --git a/indra/llcharacter/llmultigesture.cpp b/indra/llcharacter/llmultigesture.cpp
index f5afd3cee6e..644765cf1db 100644
--- a/indra/llcharacter/llmultigesture.cpp
+++ b/indra/llcharacter/llmultigesture.cpp
@@ -466,24 +466,24 @@ BOOL LLGestureStepWait::deserialize(LLDataPacker& dp)
 std::vector<std::string> LLGestureStepWait::getLabel() const
 {
 	std::vector<std::string> strings;
-	strings.push_back( "Wait" );
+	strings.emplace_back( "Wait" );
 	
 //	std::string label("--- Wait: ");
 	if (mFlags & WAIT_FLAG_TIME)
 	{
-		char buffer[64];		/* Flawfinder: ignore */
-		snprintf(buffer, sizeof(buffer), "%.1f seconds", (double)mWaitSeconds);	/* Flawfinder: ignore */
-		strings.push_back(buffer);
+		std::string str = absl::StrFormat("%.1f seconds", mWaitSeconds);
+
+		strings.push_back(std::move(str));
 //		label += buffer;
 	}
 	else if (mFlags & WAIT_FLAG_ALL_ANIM)
 	{
-		strings.push_back("until animations are done");
+		strings.emplace_back("until animations are done");
 	//	label += "until animations are done";
 	}
 	else
 	{
-		strings.push_back("");
+		strings.emplace_back("");
 	}
 
 	return strings;
diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp
index d6fd4669c75..3a83ddc8949 100644
--- a/indra/llcorehttp/_httpoprequest.cpp
+++ b/indra/llcorehttp/_httpoprequest.cpp
@@ -670,29 +670,24 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
 	// There's a CURLOPT for this now...
 	if ((mReqOffset || mReqLength) && HOR_GET == mReqMethod)
 	{
-		static const char * const fmt1("Range: bytes=%lu-%lu");
-		static const char * const fmt2("Range: bytes=%lu-");
+		constexpr absl::string_view fmt1 = "Range: bytes=%lu-%lu";
+		constexpr absl::string_view fmt2 = "Range: bytes=%lu-";
 
 		char range_line[64];
 
-#if LL_WINDOWS
-		_snprintf_s(range_line, sizeof(range_line), sizeof(range_line) - 1,
-					(mReqLength ? fmt1 : fmt2),
-					(unsigned long) mReqOffset, (unsigned long) (mReqOffset + mReqLength - 1));
-#else
 		if ( mReqLength )
 		{
-			snprintf(range_line, sizeof(range_line),
+			absl::SNPrintF(range_line, sizeof(range_line),
 					 fmt1,
 					 (unsigned long) mReqOffset, (unsigned long) (mReqOffset + mReqLength - 1));
 		}
 		else
 		{
-			snprintf(range_line, sizeof(range_line),
+			absl::SNPrintF(range_line, sizeof(range_line),
 					 fmt2,
 					 (unsigned long) mReqOffset);
 		}
-#endif // LL_WINDOWS
+
 		range_line[sizeof(range_line) - 1] = '\0';
 		mCurlHeaders = curl_slist_append(mCurlHeaders, range_line);
 	}
diff --git a/indra/llcorehttp/examples/http_texture_load.cpp b/indra/llcorehttp/examples/http_texture_load.cpp
index e8b806059d1..77bd3e1c77e 100644
--- a/indra/llcorehttp/examples/http_texture_load.cpp
+++ b/indra/llcorehttp/examples/http_texture_load.cpp
@@ -455,11 +455,9 @@ bool WorkingSet::reload(LLCore::HttpRequest * hr, LLCore::HttpOptions::ptr_t & o
 	for (int i(0); i < to_do; ++i)
 	{
 		char buffer[1024];
-#if	defined(WIN32)
-		_snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1, mUrl.c_str(), mAssets[mAt].mUuid.c_str());
-#else
-		snprintf(buffer, sizeof(buffer), mUrl.c_str(), mAssets[mAt].mUuid.c_str());
-#endif
+
+		absl::SNPrintF(buffer, sizeof(buffer), mUrl.c_str(), mAssets[mAt].mUuid.c_str());
+
 		int offset(mNoRange
 				   ? 0
 				   : (mRandomRange ? ((unsigned long) rand()) % 1000000UL : mAssets[mAt].mOffset));
diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp
index 11f6b71f2f2..20a060e96f2 100644
--- a/indra/llcorehttp/tests/test_httprequest.hpp
+++ b/indra/llcorehttp/tests/test_httprequest.hpp
@@ -2762,7 +2762,7 @@ void HttpRequestTestObjectType::test<22>()
 		for (int i(0); i < test_count; ++i)
 		{
 			char buffer[128];
-			snprintf(buffer, sizeof(buffer), "/bug2295/%d/", i);
+			absl::SNPrintF(buffer, sizeof(buffer), "/bug2295/%d/", i);
 			HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
 														 0U,
 														 url_base + buffer,
@@ -2794,7 +2794,7 @@ void HttpRequestTestObjectType::test<22>()
 		for (int i(0); i < test2_count; ++i)
 		{
 			char buffer[128];
-			snprintf(buffer, sizeof(buffer), "/bug2295/00000012/%d/", i);
+			absl::SNPrintF(buffer, sizeof(buffer), "/bug2295/00000012/%d/", i);
 			HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
 														 0U,
 														 url_base + buffer,
@@ -2826,7 +2826,7 @@ void HttpRequestTestObjectType::test<22>()
 		for (int i(0); i < test3_count; ++i)
 		{
 			char buffer[128];
-			snprintf(buffer, sizeof(buffer), "/bug2295/inv_cont_range/%d/", i);
+			absl::SNPrintF(buffer, sizeof(buffer), "/bug2295/inv_cont_range/%d/", i);
 			HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
 														 0U,
 														 url_base + buffer,
diff --git a/indra/llmessage/lldatapacker.cpp b/indra/llmessage/lldatapacker.cpp
index 51043739266..6edb473fac6 100644
--- a/indra/llmessage/lldatapacker.cpp
+++ b/indra/llmessage/lldatapacker.cpp
@@ -622,7 +622,7 @@ void LLDataPackerBinaryBuffer::dumpBufferToLog()
 	S32 cur_line = 0;
 	for (i = 0; i < mBufferSize; i++)
 	{
-		snprintf(line_buffer + cur_line_pos*3, sizeof(line_buffer) - cur_line_pos*3, "%02x ", mBufferp[i]); 	/* Flawfinder: ignore */
+		absl::SNPrintF(line_buffer + cur_line_pos*3, sizeof(line_buffer) - cur_line_pos*3, "%02x ", mBufferp[i]); 	/* Flawfinder: ignore */
 		cur_line_pos++;
 		if (cur_line_pos >= 16)
 		{
@@ -647,7 +647,7 @@ BOOL LLDataPackerAsciiBuffer::packString(const std::string& value, const char *n
 	int numCopied = 0;
 	if (mWriteEnabled) 
 	{
-		numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", value.c_str());		/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", value.c_str());		/* Flawfinder: ignore */
 	}
 	else
 	{
@@ -691,7 +691,7 @@ BOOL LLDataPackerAsciiBuffer::packBinaryData(const U8 *value, S32 size, const ch
 	int numCopied = 0;
 	if (mWriteEnabled)
 	{
-		numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%010d ", size);	/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%010d ", size);	/* Flawfinder: ignore */
 
 		// snprintf returns number of bytes that would have been
 		// written had the output not being truncated. In that case,
@@ -711,7 +711,7 @@ BOOL LLDataPackerAsciiBuffer::packBinaryData(const U8 *value, S32 size, const ch
 		BOOL bBufferFull = FALSE;
 		for (i = 0; i < size && !bBufferFull; i++)
 		{
-			numCopied = snprintf(mCurBufferp, getBufferSize()-getCurrentSize(), "%02x ", value[i]);	/* Flawfinder: ignore */
+			numCopied = absl::SNPrintF(mCurBufferp, getBufferSize()-getCurrentSize(), "%02x ", value[i]);	/* Flawfinder: ignore */
 			if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
 			{
 				numCopied = getBufferSize()-getCurrentSize();
@@ -723,7 +723,7 @@ BOOL LLDataPackerAsciiBuffer::packBinaryData(const U8 *value, S32 size, const ch
 
 		if (!bBufferFull)
 		{
-			numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(), "\n");	/* Flawfinder: ignore */
+			numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(), "\n");	/* Flawfinder: ignore */
 			if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
 		    	{
 				numCopied = getBufferSize()-getCurrentSize();
@@ -785,7 +785,7 @@ BOOL LLDataPackerAsciiBuffer::packBinaryDataFixed(const U8 *value, S32 size, con
 		BOOL bBufferFull = FALSE;
 		for (i = 0; i < size && !bBufferFull; i++)
 		{
-			numCopied = snprintf(mCurBufferp, getBufferSize()-getCurrentSize(), "%02x ", value[i]);	/* Flawfinder: ignore */
+			numCopied = absl::SNPrintF(mCurBufferp, getBufferSize()-getCurrentSize(), "%02x ", value[i]);	/* Flawfinder: ignore */
 			if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
 			{
 			    numCopied = getBufferSize()-getCurrentSize();
@@ -797,7 +797,7 @@ BOOL LLDataPackerAsciiBuffer::packBinaryDataFixed(const U8 *value, S32 size, con
 		}
 		if (!bBufferFull)
 		{
-			numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(), "\n");	/* Flawfinder: ignore */
+			numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(), "\n");	/* Flawfinder: ignore */
 			if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
 			{
 				numCopied = getBufferSize()-getCurrentSize();
@@ -851,12 +851,12 @@ BOOL LLDataPackerAsciiBuffer::packU8(const U8 value, const char *name)
 	int numCopied = 0;
 	if (mWriteEnabled)
 	{
-	    	numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value);	/* Flawfinder: ignore */
+	    	numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value);	/* Flawfinder: ignore */
 	}
 	else
 	{
 		// just do the write to a temp buffer to get the length
-		numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value);	/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value);	/* Flawfinder: ignore */
 	}
 
 	// snprintf returns number of bytes that would have been written
@@ -899,11 +899,11 @@ BOOL LLDataPackerAsciiBuffer::packU16(const U16 value, const char *name)
 	int numCopied = 0;
 	if (mWriteEnabled)
 	{
-	    	numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value);	/* Flawfinder: ignore */
+	    	numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value);	/* Flawfinder: ignore */
 	}
 	else
 	{
-		numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value);	/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value);	/* Flawfinder: ignore */
 	}
 
 	// snprintf returns number of bytes that would have been written
@@ -947,11 +947,11 @@ BOOL LLDataPackerAsciiBuffer::packU32(const U32 value, const char *name)
 	int numCopied = 0;
 	if (mWriteEnabled)
 	{
-	    	numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%u\n", value);	/* Flawfinder: ignore */
+	    	numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%u\n", value);	/* Flawfinder: ignore */
 	}
 	else
 	{
-		numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%u\n", value);	/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%u\n", value);	/* Flawfinder: ignore */
 	}
 	// snprintf returns number of bytes that would have been written
 	// had the output not being truncated. In that case, it will
@@ -991,11 +991,11 @@ BOOL LLDataPackerAsciiBuffer::packS32(const S32 value, const char *name)
 	int numCopied = 0;
 	if (mWriteEnabled)
 	{
-	    	numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value);	/* Flawfinder: ignore */
+	    	numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value);	/* Flawfinder: ignore */
 	}
 	else
 	{
-		numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value);		/* Flawfinder: ignore */	
+		numCopied = absl::SNPrintF(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value);		/* Flawfinder: ignore */	
 	}
 	// snprintf returns number of bytes that would have been written
 	// had the output not being truncated. In that case, it will
@@ -1035,11 +1035,11 @@ BOOL LLDataPackerAsciiBuffer::packF32(const F32 value, const char *name)
 	int numCopied = 0;
 	if (mWriteEnabled)
 	{
-	    	numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%f\n", value);		/* Flawfinder: ignore */
+	    	numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%f\n", value);		/* Flawfinder: ignore */
 	}
 	else
 	{
-		numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%f\n", value);		/* Flawfinder: ignore */	
+		numCopied = absl::SNPrintF(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%f\n", value);		/* Flawfinder: ignore */	
 	}
 	// snprintf returns number of bytes that would have been written
 	// had the output not being truncated. In that case, it will
@@ -1079,11 +1079,11 @@ BOOL LLDataPackerAsciiBuffer::packColor4(const LLColor4 &value, const char *name
 	int numCopied = 0;
 	if (mWriteEnabled)
 	{
-	    	numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
+	    	numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
 	}
 	else
 	{
-		numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
 	}
 	// snprintf returns number of bytes that would have been written
 	// had the output not being truncated. In that case, it will
@@ -1122,11 +1122,11 @@ BOOL LLDataPackerAsciiBuffer::packColor4U(const LLColor4U &value, const char *na
 	int numCopied = 0;
 	if (mWriteEnabled)
 	{
-		numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d %d %d %d\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%d %d %d %d\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
 	}
 	else
 	{
-		numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%d %d %d %d\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%d %d %d %d\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
 	}
 	// snprintf returns number of bytes that would have been written
 	// had the output not being truncated. In that case, it will
@@ -1172,11 +1172,11 @@ BOOL LLDataPackerAsciiBuffer::packVector2(const LLVector2 &value, const char *na
 	int numCopied = 0;
 	if (mWriteEnabled)
 	{
-	    	numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f\n", value.mV[0], value.mV[1]);	/* Flawfinder: ignore */
+	    	numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f\n", value.mV[0], value.mV[1]);	/* Flawfinder: ignore */
 	}
 	else
 	{
-		numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f\n", value.mV[0], value.mV[1]);		/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f\n", value.mV[0], value.mV[1]);		/* Flawfinder: ignore */
 	}
 	// snprintf returns number of bytes that would have been written
 	// had the output not being truncated. In that case, it will
@@ -1216,11 +1216,11 @@ BOOL LLDataPackerAsciiBuffer::packVector3(const LLVector3 &value, const char *na
 	int numCopied = 0;
 	if (mWriteEnabled)
 	{
-	    	numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f %f\n", value.mV[0], value.mV[1], value.mV[2]);	/* Flawfinder: ignore */
+	    	numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f %f\n", value.mV[0], value.mV[1], value.mV[2]);	/* Flawfinder: ignore */
 	}
 	else
 	{
-		numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f %f\n", value.mV[0], value.mV[1], value.mV[2]);	/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f %f\n", value.mV[0], value.mV[1], value.mV[2]);	/* Flawfinder: ignore */
 	}
 	// snprintf returns number of bytes that would have been written
 	// had the output not being truncated. In that case, it will
@@ -1259,11 +1259,11 @@ BOOL LLDataPackerAsciiBuffer::packVector4(const LLVector4 &value, const char *na
 	int numCopied = 0;
 	if (mWriteEnabled)
 	{
-	    	numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
+	    	numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
 	}
 	else
 	{
-		numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%f %f %f %f\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]);	/* Flawfinder: ignore */
 	}
 	// snprintf returns number of bytes that would have been written
 	// had the output not being truncated. In that case, it will
@@ -1306,7 +1306,7 @@ BOOL LLDataPackerAsciiBuffer::packUUID(const LLUUID &value, const char *name)
 	{
 		std::string tmp_str;
 		value.toString(tmp_str);
-		numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", tmp_str.c_str());	/* Flawfinder: ignore */
+		numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", tmp_str.c_str());	/* Flawfinder: ignore */
 	}
 	else
 	{
@@ -1357,7 +1357,7 @@ void LLDataPackerAsciiBuffer::writeIndentedName(const char *name)
 		int numCopied = 0;
 		if (mWriteEnabled)
 		{
-			numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\t", name);	/* Flawfinder: ignore */
+			numCopied = absl::SNPrintF(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\t", name);	/* Flawfinder: ignore */
 		}
 		else
 		{
@@ -1430,7 +1430,7 @@ std::string convertF32ToString(F32 val)
 {
 	std::string str;
 	char  buf[20];
-	snprintf(buf, 20, "%f", val);
+	absl::SNPrintF(buf, 20, "%f", val);
 	str = buf;
 	return str;
 }
@@ -1485,13 +1485,13 @@ BOOL LLDataPackerAsciiFile::packBinaryData(const U8 *value, S32 size, const char
 	else if (mOutputStream)
 	{
 		char buffer[32];	/* Flawfinder: ignore */
-		snprintf(buffer,sizeof(buffer), "%010d ", size);	/* Flawfinder: ignore */
+		absl::SNPrintF(buffer,sizeof(buffer), "%010d ", size);	/* Flawfinder: ignore */
 		*mOutputStream << buffer;
 
 		S32 i;
 		for (i = 0; i < size; i++)
 		{
-			snprintf(buffer, sizeof(buffer), "%02x ", value[i]);	/* Flawfinder: ignore */
+			absl::SNPrintF(buffer, sizeof(buffer), "%02x ", value[i]);	/* Flawfinder: ignore */
 			*mOutputStream << buffer;
 		}
 		*mOutputStream << "\n";
@@ -1545,7 +1545,7 @@ BOOL LLDataPackerAsciiFile::packBinaryDataFixed(const U8 *value, S32 size, const
 		S32 i;
 		for (i = 0; i < size; i++)
 		{
-			snprintf(buffer, sizeof(buffer), "%02x ", value[i]);	/* Flawfinder: ignore */
+			absl::SNPrintF(buffer, sizeof(buffer), "%02x ", value[i]);	/* Flawfinder: ignore */
 			*mOutputStream << buffer;
 		}
 		*mOutputStream << "\n";
diff --git a/indra/llmessage/llinstantmessage.cpp b/indra/llmessage/llinstantmessage.cpp
index dd5a655d7eb..58fcf88b101 100644
--- a/indra/llmessage/llinstantmessage.cpp
+++ b/indra/llmessage/llinstantmessage.cpp
@@ -126,7 +126,7 @@ void pack_instant_message_block(
 	if(!message.empty())
 	{
 		char buffer[MTUBYTES];
-		int num_written = snprintf(buffer, MTUBYTES, "%s", message.c_str());	/* Flawfinder: ignore */
+		int num_written = absl::SNPrintF(buffer, MTUBYTES, "%s", message);	/* Flawfinder: ignore */
 		// snprintf returns number of bytes that would have been written
 		// had the output not being truncated. In that case, it will
 		// return either -1 or value >= passed in size value . So a check needs to be added
diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp
index 06fe866dbfd..89ffcf0b5cd 100644
--- a/indra/llmessage/message.cpp
+++ b/indra/llmessage/message.cpp
@@ -3110,7 +3110,7 @@ bool LLMessageSystem::generateDigestForNumberAndUUIDs(
 
 	d.update((const unsigned char *) colon, (U32)strlen(colon));	/* Flawfinder: ignore */ 
 	
-	snprintf(tbuf, sizeof(tbuf),"%i", number);		/* Flawfinder: ignore */
+	absl::SNPrintF(tbuf, sizeof(tbuf),"%i", number);		/* Flawfinder: ignore */
 	d.update((unsigned char *) tbuf, (U32)strlen(tbuf));	/* Flawfinder: ignore */ 
 	
 	d.update((const unsigned char *) colon, (U32)strlen(colon));	/* Flawfinder: ignore */ 
@@ -3372,7 +3372,7 @@ void LLMessageSystem::dumpPacketToLog()
 	for (i = 0; i < mTrueReceiveSize; i++)
 	{
 		S32 offset = cur_line_pos * 3;
-		snprintf(line_buffer + offset, sizeof(line_buffer) - offset,
+		absl::SNPrintF(line_buffer + offset, sizeof(line_buffer) - offset,
 				 "%02x ", mTrueReceiveBuffer[i]);	/* Flawfinder: ignore */
 		cur_line_pos++;
 		if (cur_line_pos >= 16)
diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp
index fa1a5e1af1f..789058abf4a 100644
--- a/indra/llprimitive/lldaeloader.cpp
+++ b/indra/llprimitive/lldaeloader.cpp
@@ -1244,7 +1244,7 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
                     {
                         //Build a joint for the resolver to work with
                         char str[64]={};
-                        snprintf(str, sizeof(str), "./%s", (*jointIt).first.c_str() );
+                        absl::SNPrintF(str, sizeof(str), "./%s", (*jointIt).first.c_str() );
                         //LL_WARNS()<<"Joint "<< str <<LL_ENDL;
 
                         //Setup the resolver
diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp
index 284dfc15f46..b10b5b4c995 100644
--- a/indra/llprimitive/lltextureentry.cpp
+++ b/indra/llprimitive/lltextureentry.cpp
@@ -626,10 +626,10 @@ std::string LLTextureEntry::touchMediaVersionString(const std::string &in_versio
     // where "nnnnn" is version number
     // *NOTE: not the most efficient code in the world...
     U32 current_version = getVersionFromMediaVersionString(in_version) + 1;
-    const size_t MAX_VERSION_LEN = 10; // 2^32 fits in 10 decimal digits
+    constexpr size_t MAX_VERSION_LEN = 10; // 2^32 fits in 10 decimal digits
     char buf[MAX_VERSION_LEN+1];
-    snprintf(buf, (int)MAX_VERSION_LEN+1, "%0*u", (int)MAX_VERSION_LEN, current_version);  // added int cast to fix warning/breakage on mac.
-    return MEDIA_VERSION_STRING_PREFIX + buf + "/" + agent_id.asString();
+	absl::SNPrintF(buf, MAX_VERSION_LEN+1, "%0*u", MAX_VERSION_LEN, current_version);  // added int cast to fix warning/breakage on mac.
+    return absl::StrCat(MEDIA_VERSION_STRING_PREFIX, buf, "/", agent_id.asString());
 }
 
 //static
diff --git a/indra/llrender/llgldbg.cpp b/indra/llrender/llgldbg.cpp
index e316ea7c824..dc455a583d1 100644
--- a/indra/llrender/llgldbg.cpp
+++ b/indra/llrender/llgldbg.cpp
@@ -79,7 +79,7 @@ const char *boolstr(int b)
 const char *fv4(F32 *f)
 {
 	static char str[128];
-	snprintf(str, sizeof(str), "%8.3f %8.3f %8.3f %8.3f", f[0], f[1], f[2], f[3]);
+	absl::SNPrintF(str, sizeof(str), "%8.3f %8.3f %8.3f %8.3f", f[0], f[1], f[2], f[3]);
 	return str;
 }
 
@@ -89,7 +89,7 @@ const char *fv4(F32 *f)
 const char *fv3(F32 *f)
 {
 	static char str[128];	/* Flawfinder: ignore */
-	snprintf(str, sizeof(str), "%8.3f, %8.3f, %8.3f", f[0], f[1], f[2]);	/* Flawfinder: ignore */
+	absl::SNPrintF(str, sizeof(str), "%8.3f, %8.3f, %8.3f", f[0], f[1], f[2]);	/* Flawfinder: ignore */
 	return str;
 }
 
@@ -99,7 +99,7 @@ const char *fv3(F32 *f)
 const char *fv1(F32 *f)
 {
 	static char str[128];	/* Flawfinder: ignore */
-	snprintf(str, sizeof(str), "%8.3f", f[0]);		/* Flawfinder: ignore */
+	absl::SNPrintF(str, sizeof(str), "%8.3f", f[0]);		/* Flawfinder: ignore */
 	return str;
 }
 
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 14e05fd4409..b4184e6e36b 100644
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -92,7 +92,7 @@ const char *makeNewAutoName()
 {
     static char name[64];
     static S32 auto_namer_number = 0;
-    snprintf(name,64,"auto_name_%d",auto_namer_number);
+    absl::SNPrintF(name,64,"auto_name_%d",auto_namer_number);
     auto_namer_number++;
     return name;
 }
-- 
GitLab