summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2023-10-17 06:33:05 -0400
committerNat Goodspeed <nat@lindenlab.com>2023-10-17 06:33:05 -0400
commit117f07e5a4b7882a44681c730dcc0628238cfec6 (patch)
tree5cf60970252ad671fdd352062ae41950f318a82b /indra/newview
parent19f453fc2007f780ae5d819090db206f07d0a9c6 (diff)
SL-18837: Avoid stuffing build number into 32-bit int.
Even though LLVersionInfo::getBuild() already returns a 64-bit int, various consumers assumed it could fit into 32 bits. It was especially bad to pass it to a classic C style varargs function. Only on a little-endian CPU, and only because it was the last argument, the damage was limited to truncation -- instead of arbitrary undefined behavior. Where the consumer doesn't support 64-bit ints, pass as string instead.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llappviewer.cpp4
-rw-r--r--indra/newview/llcurrencyuimanager.cpp13
-rw-r--r--indra/newview/llpanellogin.cpp13
-rw-r--r--indra/newview/lltranslate.cpp25
-rw-r--r--indra/newview/llversioninfo.cpp4
-rw-r--r--indra/newview/llversioninfo.h2
-rw-r--r--indra/newview/llxmlrpctransaction.cpp15
7 files changed, 42 insertions, 34 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index dec849afa1..5763ebe721 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -3209,8 +3209,10 @@ LLSD LLAppViewer::getViewerInfo() const
// LLFloaterAbout.
LLSD info;
auto& versionInfo(LLVersionInfo::instance());
+ // With GitHub builds, the build number is too big to fit in a 32-bit int,
+ // and LLSD doesn't deal with integers wider than int. Use string.
info["VIEWER_VERSION"] = llsd::array(versionInfo.getMajor(), versionInfo.getMinor(),
- versionInfo.getPatch(), versionInfo.getBuild());
+ versionInfo.getPatch(), stringize(versionInfo.getBuild()));
info["VIEWER_VERSION_STR"] = versionInfo.getVersion();
info["CHANNEL"] = versionInfo.getChannel();
info["ADDRESS_SIZE"] = ADDRESS_SIZE;
diff --git a/indra/newview/llcurrencyuimanager.cpp b/indra/newview/llcurrencyuimanager.cpp
index 232e461fd0..4c0a5cf183 100644
--- a/indra/newview/llcurrencyuimanager.cpp
+++ b/indra/newview/llcurrencyuimanager.cpp
@@ -45,6 +45,7 @@
#include "llxmlrpctransaction.h"
#include "llviewernetwork.h"
#include "llpanel.h"
+#include "stringize.h"
const F64 CURRENCY_ESTIMATE_FREQUENCY = 2.0;
@@ -158,7 +159,7 @@ void LLCurrencyUIManager::Impl::updateCurrencyInfo()
mLocalCurrencyEstimated = true;
return;
}
-
+
LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct();
keywordArgs.appendString("agentId", gAgent.getID().asString());
keywordArgs.appendString(
@@ -170,8 +171,10 @@ void LLCurrencyUIManager::Impl::updateCurrencyInfo()
keywordArgs.appendInt("viewerMajorVersion", LLVersionInfo::instance().getMajor());
keywordArgs.appendInt("viewerMinorVersion", LLVersionInfo::instance().getMinor());
keywordArgs.appendInt("viewerPatchVersion", LLVersionInfo::instance().getPatch());
- keywordArgs.appendInt("viewerBuildVersion", LLVersionInfo::instance().getBuild());
-
+ // With GitHub builds, the build number is too big to fit in a 32-bit int,
+ // and XMLRPC_VALUE doesn't deal with integers wider than int. Use string.
+ keywordArgs.appendString("viewerBuildVersion", stringize(LLVersionInfo::instance().getBuild()));
+
LLXMLRPCValue params = LLXMLRPCValue::createArray();
params.append(keywordArgs);
@@ -245,7 +248,9 @@ void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password)
keywordArgs.appendInt("viewerMajorVersion", LLVersionInfo::instance().getMajor());
keywordArgs.appendInt("viewerMinorVersion", LLVersionInfo::instance().getMinor());
keywordArgs.appendInt("viewerPatchVersion", LLVersionInfo::instance().getPatch());
- keywordArgs.appendInt("viewerBuildVersion", LLVersionInfo::instance().getBuild());
+ // With GitHub builds, the build number is too big to fit in a 32-bit int,
+ // and XMLRPC_VALUE doesn't deal with integers wider than int. Use string.
+ keywordArgs.appendString("viewerBuildVersion", stringize(LLVersionInfo::instance().getBuild()));
LLXMLRPCValue params = LLXMLRPCValue::createArray();
params.append(keywordArgs);
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index ea936ab024..025a653c47 100644
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -65,6 +65,7 @@
#include "lltrans.h"
#include "llglheaders.h"
#include "llpanelloginlistener.h"
+#include "stringize.h"
#if LL_WINDOWS
#pragma warning(disable: 4355) // 'this' used in initializer list
@@ -300,10 +301,9 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
setDefaultBtn(def_btn);
std::string channel = LLVersionInfo::instance().getChannel();
- std::string version = llformat("%s (%ld)",
- LLVersionInfo::instance().getShortVersion().c_str(),
- LLVersionInfo::instance().getBuild());
-
+ std::string version = stringize(LLVersionInfo::instance().getShortVersion(), " (",
+ LLVersionInfo::instance().getBuild(), ')');
+
LLTextBox* forgot_password_text = getChild<LLTextBox>("forgot_password_text");
forgot_password_text->setClickedCallback(onClickForgotPassword, NULL);
@@ -894,9 +894,8 @@ void LLPanelLogin::loadLoginPage()
}
// Channel and Version
- params["version"] = llformat("%s (%ld)",
- LLVersionInfo::instance().getShortVersion().c_str(),
- LLVersionInfo::instance().getBuild());
+ params["version"] = stringize(LLVersionInfo::instance().getShortVersion(), " (",
+ LLVersionInfo::instance().getBuild(), ')');
params["channel"] = LLVersionInfo::instance().getChannel();
// Grid
diff --git a/indra/newview/lltranslate.cpp b/indra/newview/lltranslate.cpp
index 1e21c3fa05..6526e1df92 100644
--- a/indra/newview/lltranslate.cpp
+++ b/indra/newview/lltranslate.cpp
@@ -39,6 +39,7 @@
#include "json/reader.h"
#include "llcorehttputil.h"
#include "llurlregistry.h"
+#include "stringize.h"
static const std::string AZURE_NOTRANSLATE_OPENING_TAG("<div translate=\"no\">");
@@ -160,12 +161,12 @@ void LLTranslationAPIHandler::verifyKeyCoro(LLTranslate::EService service, LLSD
LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
- std::string user_agent = llformat("%s %d.%d.%d (%ld)",
- LLVersionInfo::instance().getChannel().c_str(),
- LLVersionInfo::instance().getMajor(),
- LLVersionInfo::instance().getMinor(),
- LLVersionInfo::instance().getPatch(),
- LLVersionInfo::instance().getBuild());
+ std::string user_agent = stringize(
+ LLVersionInfo::instance().getChannel(), ' ',
+ LLVersionInfo::instance().getMajor(), '.',
+ LLVersionInfo::instance().getMinor(), '.',
+ LLVersionInfo::instance().getPatch(), " (",
+ LLVersionInfo::instance().getBuild(), ')');
initHttpHeader(httpHeaders, user_agent, key);
@@ -215,12 +216,12 @@ void LLTranslationAPIHandler::translateMessageCoro(LanguagePair_t fromTo, std::s
LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders);
- std::string user_agent = llformat("%s %d.%d.%d (%ld)",
- LLVersionInfo::instance().getChannel().c_str(),
- LLVersionInfo::instance().getMajor(),
- LLVersionInfo::instance().getMinor(),
- LLVersionInfo::instance().getPatch(),
- LLVersionInfo::instance().getBuild());
+ std::string user_agent = stringize(
+ LLVersionInfo::instance().getChannel(), ' ',
+ LLVersionInfo::instance().getMajor(), '.',
+ LLVersionInfo::instance().getMinor(), '.',
+ LLVersionInfo::instance().getPatch(), " (",
+ LLVersionInfo::instance().getBuild(), ')');
initHttpHeader(httpHeaders, user_agent);
httpOpts->setSSLVerifyPeer(false);
diff --git a/indra/newview/llversioninfo.cpp b/indra/newview/llversioninfo.cpp
index 62bfa24e29..9551df7bee 100644
--- a/indra/newview/llversioninfo.cpp
+++ b/indra/newview/llversioninfo.cpp
@@ -69,7 +69,7 @@ void LLVersionInfo::initSingleton()
// fully constructed; such calls don't really belong in the constructor.
// cache the version string
- version = STRINGIZE(getShortVersion() << "." << getBuild());
+ version = stringize(getShortVersion(), ".", getBuild());
}
LLVersionInfo::~LLVersionInfo()
@@ -91,7 +91,7 @@ S32 LLVersionInfo::getPatch()
return LL_VIEWER_VERSION_PATCH;
}
-S64 LLVersionInfo::getBuild()
+U64 LLVersionInfo::getBuild()
{
return LL_VIEWER_VERSION_BUILD;
}
diff --git a/indra/newview/llversioninfo.h b/indra/newview/llversioninfo.h
index 122bd5c47a..a40042380a 100644
--- a/indra/newview/llversioninfo.h
+++ b/indra/newview/llversioninfo.h
@@ -61,7 +61,7 @@ public:
S32 getPatch();
/// return the build number as an integer
- S64 getBuild();
+ U64 getBuild();
/// return the full viewer version as a string like "2.0.0.200030"
std::string getVersion();
diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp
index b851b7ad5c..8ea07fcee0 100644
--- a/indra/newview/llxmlrpctransaction.cpp
+++ b/indra/newview/llxmlrpctransaction.cpp
@@ -42,6 +42,7 @@
#include "bufferarray.h"
#include "llversioninfo.h"
#include "llviewercontrol.h"
+#include "stringize.h"
// Have to include these last to avoid queue redefinition!
@@ -384,14 +385,14 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip, const
httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_TEXT_XML);
- std::string user_agent = llformat("%s %d.%d.%d (%ld)",
- LLVersionInfo::instance().getChannel().c_str(),
- LLVersionInfo::instance().getMajor(),
- LLVersionInfo::instance().getMinor(),
- LLVersionInfo::instance().getPatch(),
- LLVersionInfo::instance().getBuild());
+ std::string user_agent = stringize(
+ LLVersionInfo::instance().getChannel(), ' ',
+ LLVersionInfo::instance().getMajor(), '.',
+ LLVersionInfo::instance().getMinor(), '.',
+ LLVersionInfo::instance().getPatch(), " (",
+ LLVersionInfo::instance().getBuild(), ')');
- httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, user_agent);
+ httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, user_agent);
///* Setting the DNS cache timeout to -1 disables it completely.
//This might help with bug #503 */