From 4c31f60bba890e5c320c4bc6fd0ca1c5ce741830 Mon Sep 17 00:00:00 2001
From: Lynx Linden <lynx@lindenlab.com>
Date: Tue, 22 Jun 2010 18:33:39 +0100
Subject: EXT-7926 FIXED Fixed crash opening About for non-English locales.

Calling std::locale("fr_FR.UTF-8") crashes on Linux and Mac. Or
rather, it throws an exception when it doesn't know the locale and we
didn't handle the exception. I now catch the exception and output an
error rather than crash.

Note, this happened because of change 703f3bcf7069, which made us
actually pass a real locale string instead of just "C". So, we were
never actually supporting a locale for LLStringUtil::formatNumber().
There is therefore an open task of making formatNumber() actually
respect the locale. I'll report a separate JIRA to capture that task.
---
 indra/llcommon/llstring.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'indra/llcommon')

diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index f14d947734..f5eb552d99 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -994,7 +994,14 @@ void LLStringUtil::formatNumber(std::string& numStr, std::string decimals)
 	convertToS32 (decimals, intDecimals);
 	if (!sLocale.empty())
 	{
-		strStream.imbue (std::locale(sLocale.c_str()));
+		// imbue() throws if the locale is unknown! (EXT-7926)
+		try
+		{
+			strStream.imbue(std::locale(sLocale.c_str()));
+		} catch (const std::exception &e)
+		{
+			LL_WARNS_ONCE("Locale") << "Cannot set locale to " << sLocale << LL_ENDL;
+		}
 	}
 
 	if (!intDecimals)
-- 
cgit v1.2.3


From ccad528d5fb5889e9826ca045de5e7315be5942e Mon Sep 17 00:00:00 2001
From: Lynx Linden <lynx@lindenlab.com>
Date: Tue, 22 Jun 2010 18:55:04 +0100
Subject: EXT-7926 FIXED Minor typo correction.

---
 indra/llcommon/llstring.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/llcommon')

diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index f5eb552d99..ffdac5d411 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -994,7 +994,7 @@ void LLStringUtil::formatNumber(std::string& numStr, std::string decimals)
 	convertToS32 (decimals, intDecimals);
 	if (!sLocale.empty())
 	{
-		// imbue() throws if the locale is unknown! (EXT-7926)
+		// std::locale() throws if the locale is unknown! (EXT-7926)
 		try
 		{
 			strStream.imbue(std::locale(sLocale.c_str()));
-- 
cgit v1.2.3


From dfc20a824944d372c6978ca7b89289ec542554a9 Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Tue, 22 Jun 2010 14:59:34 -0400
Subject: EXT-7926: Remove unreferenced catch-clause variable (MSVC error).

---
 indra/llcommon/llstring.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/llcommon')

diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index ffdac5d411..1561bda201 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -998,7 +998,7 @@ void LLStringUtil::formatNumber(std::string& numStr, std::string decimals)
 		try
 		{
 			strStream.imbue(std::locale(sLocale.c_str()));
-		} catch (const std::exception &e)
+		} catch (const std::exception &)
 		{
 			LL_WARNS_ONCE("Locale") << "Cannot set locale to " << sLocale << LL_ENDL;
 		}
-- 
cgit v1.2.3


From 87082996e6408919591ee3d408918a4425494dc9 Mon Sep 17 00:00:00 2001
From: "Andrew A. de Laix" <alain@lindenlab.com>
Date: Tue, 22 Jun 2010 15:19:16 -0700
Subject: Revert to previous implementation of getNodeId.

---
 indra/llcommon/lluuid.cpp | 116 ++++++++++++++--------------------------------
 1 file changed, 34 insertions(+), 82 deletions(-)

(limited to 'indra/llcommon')

diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp
index 583c1e589b..3bab01715a 100644
--- a/indra/llcommon/lluuid.cpp
+++ b/indra/llcommon/lluuid.cpp
@@ -456,101 +456,53 @@ static void get_random_bytes(void *buf, int nbytes)
 }
 
 #if	LL_WINDOWS
-// Code	copied from	http://msdn.microsoft.com/en-us/library/aa365939(VS.85).aspx
-// This	code grabs the first hardware	address, rather	than the first interface.
-// Using a VPN can cause the first returned	interface	to be	changed.
-
-const	S32	MAC_ADDRESS_BYTES=6;
 
+typedef struct _ASTAT_
+{
+	ADAPTER_STATUS adapt;
+	NAME_BUFFER    NameBuff [30];
+}ASTAT, * PASTAT;
 
 // static
 S32	LLUUID::getNodeID(unsigned char	*node_id)
 {
+	ASTAT Adapter;
+	NCB Ncb;
+	UCHAR uRetCode;
+	LANA_ENUM   lenum;
+	int      i;
+	int retval = 0;
 
-	// Declare and initialize variables.
-	DWORD	dwSize = 0;
-	DWORD	dwRetVal = 0;
-	int	i;
-
-/* variables used	for	GetIfTable and GetIfEntry	*/
-	MIB_IFTABLE	*pIfTable;
-	MIB_IFROW	*pIfRow;
+	memset( &Ncb, 0, sizeof(Ncb) );
+	Ncb.ncb_command = NCBENUM;
+	Ncb.ncb_buffer = (UCHAR *)&lenum;
+	Ncb.ncb_length = sizeof(lenum);
+	uRetCode = Netbios( &Ncb );
 
-	// Allocate	memory for our pointers.
-	pIfTable = (MIB_IFTABLE	*) malloc(sizeof (MIB_IFTABLE));
-	if (pIfTable ==	NULL)	
+	for(i=0; i < lenum.length ;i++)
 	{
-			printf("Error allocating memory needed to call GetIfTable\n");
-			return 0;
-	}
+		memset( &Ncb, 0, sizeof(Ncb) );
+		Ncb.ncb_command = NCBRESET;
+		Ncb.ncb_lana_num = lenum.lana[i];
 
-	// Before	calling	GetIfEntry,	we call	GetIfTable to	make
-	// sure	there	are	entries	to get and retrieve	the	interface	index.
+		uRetCode = Netbios( &Ncb );
 
-	// Make	an initial call	to GetIfTable	to get the
-	// necessary size	into dwSize
-	if (GetIfTable(pIfTable, &dwSize,	0) ==	ERROR_INSUFFICIENT_BUFFER) {
-			free(pIfTable);
-			pIfTable = (MIB_IFTABLE	*) malloc(dwSize);
-			if (pIfTable ==	NULL)	
-			{
-					printf("Error	allocating memory\n");
-					return 0;
-			}
-	}
-	//	Make a second	call to	GetIfTable to	get	the	actual
-	// data	we want.
-	if ((dwRetVal = GetIfTable(pIfTable, &dwSize,	0))	== NO_ERROR) 
-	{
-		if (pIfTable->dwNumEntries > 0)	
-		{
-			pIfRow = (MIB_IFROW	*) malloc(sizeof (MIB_IFROW));
-			if (pIfRow ==	NULL)	
-			{
-					printf("Error allocating memory\n");
-					if (pIfTable != NULL)	
-					{
-						free(pIfTable);
-						pIfTable = NULL;
-					}
-					return 0;
-			}
+		memset( &Ncb, 0, sizeof (Ncb) );
+		Ncb.ncb_command = NCBASTAT;
+		Ncb.ncb_lana_num = lenum.lana[i];
 
-			int	limit	=	MAC_ADDRESS_BYTES;
-			memcpy(node_id,	"\0\0\0\0\0\0",	limit);	// zero	out	array	of bytes	 
-			for	(i = 0;	i < (int) pIfTable->dwNumEntries; i++) 
-			{
-				pIfRow->dwIndex	= pIfTable->table[i].dwIndex;
-				if ((dwRetVal = GetIfEntry(pIfRow)) == NO_ERROR) 
-				{
-					switch (pIfRow->dwType)	
-					{
-						case IF_TYPE_ETHERNET_CSMACD:
-						case IF_TYPE_IEEE80211:		 
-							 limit = min((int) pIfRow->dwPhysAddrLen, limit);
-							 if	(pIfRow->dwPhysAddrLen == 0)
-									 break;
-							 memcpy(node_id, (UCHAR *)&pIfRow->bPhysAddr[0], limit);		 //	just incase	the	PhysAddr is	not	the	expected MAC_Address size
-							 free(pIfTable);
-							 return 1;	//return first hardware	device found.	
-							break;
-
-						case IF_TYPE_OTHER:
-						case IF_TYPE_PPP:										 
-						case IF_TYPE_SOFTWARE_LOOPBACK:										 
-						case IF_TYPE_ISO88025_TOKENRING:										
-						case IF_TYPE_IEEE1394:																		
-						case IF_TYPE_ATM:										 
-						case IF_TYPE_TUNNEL:										
-								default:
-									break;
-					}
-				}
-			}
+		strcpy( (char *)Ncb.ncb_callname,  "*              " );		/* Flawfinder: ignore */
+		Ncb.ncb_buffer = (unsigned char *)&Adapter;
+		Ncb.ncb_length = sizeof(Adapter);
+
+		uRetCode = Netbios( &Ncb );
+		if ( uRetCode == 0 )
+		{
+			memcpy(node_id,Adapter.adapt.adapter_address,6);		/* Flawfinder: ignore */
+			retval = 1;
 		}
 	}
-	free(pIfTable);
-	return 0;
+	return retval;
 }
 
 #elif LL_DARWIN
-- 
cgit v1.2.3