diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp index 583c1e589b473158536fe4e396b2729c590732b2..3bab01715ae1e3eff8415d2f3f845428ef4f5b7d 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 diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 3b8f88733a74a80ff51db6e4a5b91d0a551e9272..fc78fef6d04dd9a4cce0f6c14992b041fea209f7 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -82,6 +82,7 @@ class LLAgentCamera void init(); void cleanup(); void setAvatarObject(LLVOAvatarSelf* avatar); + bool isInitialized() { return mInitialized; } private: bool mInitialized; diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 71604291e192000f5419e481e148e29d49d12cd2..06f490e8e3a4306bb4890c9353b4e1e1c26a8bdf 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -168,7 +168,9 @@ void LLLoginInstance::constructAuthParams(LLPointer<LLCredential> user_credentia char hashed_mac_string[MD5HEX_STR_SIZE]; /* Flawfinder: ignore */ LLMD5 hashed_mac; unsigned char MACAddress[MAC_ADDRESS_BYTES]; - LLUUID::getNodeID(MACAddress); + if(LLUUID::getNodeID(MACAddress) == 0) { + llerrs << "Failed to get node id; cannot uniquely identify this machine." << llendl; + } hashed_mac.update( MACAddress, MAC_ADDRESS_BYTES ); hashed_mac.finalize(); hashed_mac.hex_digest(hashed_mac_string); diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index d7190f26a36e1da5bacc642a50793b1467cb04e8..34e30b3ccd1e431845bd9922ee9c079aeacd2fdd 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -763,7 +763,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg) } // Sort the static instance list using our interest criteria - std::stable_sort(sViewerMediaImplList.begin(), sViewerMediaImplList.end(), priorityComparitor); + sViewerMediaImplList.sort(priorityComparitor); // Go through the list again and adjust according to priority. iter = sViewerMediaImplList.begin(); diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index 8626f4469e332fcda197cc801bf55db2d68960f0..ef9c07c6c78814eec29db34cea1e79ec560ff511 100644 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -84,7 +84,7 @@ class LLViewerMedia static const char* SHOW_MEDIA_WITHIN_PARCEL_SETTING; static const char* SHOW_MEDIA_OUTSIDE_PARCEL_SETTING; - typedef std::vector<LLViewerMediaImpl*> impl_list; + typedef std::list<LLViewerMediaImpl*> impl_list; typedef std::map<LLUUID, LLViewerMediaImpl*> impl_id_map; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index ee89680fea62f4c10d35ce767ee974d6159f3fac..9027caa4ce8abd7a5d421d44ed8256287e556376 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4928,6 +4928,11 @@ void LLViewerObject::setIncludeInSearch(bool include_in_search) void LLViewerObject::setRegion(LLViewerRegion *regionp) { + if (!regionp) + { + llwarns << "viewer object set region to NULL" << llendl; + } + mLatestRecvPacketID = 0; mRegionp = regionp; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 752aeaaab01a157c7d58c6e3f40751d1fa3ca96a..fc94fbafac7c6ab2ad16e15205525d66b61371b1 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -894,10 +894,10 @@ void LLViewerObjectList::removeDrawable(LLDrawable* drawablep) BOOL LLViewerObjectList::killObject(LLViewerObject *objectp) { - // Don't ever kill gAgentAvatarp, just mark it as null region instead. + // Don't ever kill gAgentAvatarp, just force it to the agent's region if (objectp == gAgentAvatarp) { - objectp->setRegion(NULL); + objectp->setRegion(gAgent.getRegion()); return FALSE; } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index c9c0b72528dfa904e46e9544c9f43b441fa43558..6346ac320b1dc7e0d447f3c3049658a578ac364f 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2329,7 +2329,9 @@ void LLViewerWindow::handleScrollWheel(S32 clicks) // Zoom the camera in and out behavior - if(top_ctrl == 0 && getWorldViewRectScaled().pointInRect(mCurrentMousePoint.mX, mCurrentMousePoint.mY) ) + if(top_ctrl == 0 + && getWorldViewRectScaled().pointInRect(mCurrentMousePoint.mX, mCurrentMousePoint.mY) + && gAgentCamera.isInitialized()) gAgentCamera.handleScrollWheel(clicks); return;