[commit] r2170 - in trunk/SDK: BON/Common Java/native/JavaCompRegister Java/native/JavaCompRunner

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Wed Apr 10 09:03:01 CDT 2013


Author: ksmyth
Date: Wed Apr 10 09:03:01 2013
New Revision: 2170

Log:
RegQueryValueEx on string may return a string that is not null terminated

Modified:
   trunk/SDK/BON/Common/ComponentDll.cpp
   trunk/SDK/Java/native/JavaCompRegister/DlgRegisterJavaComp.cpp
   trunk/SDK/Java/native/JavaCompRunner/ComponentDll.cpp
   trunk/SDK/Java/native/JavaCompRunner/RawComponent.cpp

Modified: trunk/SDK/BON/Common/ComponentDll.cpp
==============================================================================
--- trunk/SDK/BON/Common/ComponentDll.cpp	Wed Apr 10 08:46:31 2013	(r2169)
+++ trunk/SDK/BON/Common/ComponentDll.cpp	Wed Apr 10 09:03:01 2013	(r2170)
@@ -89,6 +89,7 @@
 		if (RegQueryValueEx(hKey, _T("AfxSetAmbientActCtxMod"), NULL, &dwKeyDataType,
 							(LPBYTE) &szData, &dwDataBufSize) == ERROR_SUCCESS)
 		{
+			szData[dwDataBufSize] = '\0';
 			uAfxSetAmbientActCtxMod = _tcstoul(szData, NULL, 10);
 		}
 

Modified: trunk/SDK/Java/native/JavaCompRegister/DlgRegisterJavaComp.cpp
==============================================================================
--- trunk/SDK/Java/native/JavaCompRegister/DlgRegisterJavaComp.cpp	Wed Apr 10 08:46:31 2013	(r2169)
+++ trunk/SDK/Java/native/JavaCompRegister/DlgRegisterJavaComp.cpp	Wed Apr 10 09:03:01 2013	(r2170)
@@ -111,6 +111,7 @@
             AfxMessageBox( "Error! Could not register java component. JavaCompRunner.dll is not registered properly." );
             return;
         }
+        dllPath[len] = '\0';
       
         // register under CLSID
         sprintf(buf, "CLSID\\%s\\InprocServer32", m_strGuid);

Modified: trunk/SDK/Java/native/JavaCompRunner/ComponentDll.cpp
==============================================================================
--- trunk/SDK/Java/native/JavaCompRunner/ComponentDll.cpp	Wed Apr 10 08:46:31 2013	(r2169)
+++ trunk/SDK/Java/native/JavaCompRunner/ComponentDll.cpp	Wed Apr 10 09:03:01 2013	(r2170)
@@ -123,7 +123,8 @@
         sprintf( buf, "SOFTWARE\\GME\\Components\\%s", componentName );
         VERIFYTHROW(RegOpenKeyEx(root, buf, 0, KEY_READ, &component )==ERROR_SUCCESS);
         if(RegQueryValueEx(component, "JavaClassPath", NULL, NULL, (unsigned char*)classPath, &len ) == ERROR_SUCCESS)
-        {                   
+        {
+            classPath[len] = '\0';
             // Java component!
 
             // query clsid
@@ -133,13 +134,15 @@
             sprintf( buf, "%s\\CLSID", componentName );
             VERIFYTHROW(RegOpenKeyEx(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &clsidkey)==ERROR_SUCCESS);
             VERIFYTHROW(RegQueryValueEx(clsidkey, "", NULL, NULL, (unsigned char*)buf2, &len) == ERROR_SUCCESS);
+            buf2[len] = '\0';
             CComBSTR clsidBstr( buf2 );             
             COMTHROW(CLSIDFromString(clsidBstr,&clsid));
 
             // query class
             len = 2000;
             jclass[0] = 0;
-            RegQueryValueEx(component, "JavaClass", NULL, NULL, (unsigned char*)jclass, &len );
+            if (RegQueryValueEx(component, "JavaClass", NULL, NULL, (unsigned char*)jclass, &len ) == ERROR_SUCCESS)
+                jclass[len] = '\0';
 
             // create factory
             CJavaCompFactory * fac = new CJavaCompFactory(clsid, RUNTIME_CLASS(CComponentObj), FALSE, componentName);

Modified: trunk/SDK/Java/native/JavaCompRunner/RawComponent.cpp
==============================================================================
--- trunk/SDK/Java/native/JavaCompRunner/RawComponent.cpp	Wed Apr 10 08:46:31 2013	(r2169)
+++ trunk/SDK/Java/native/JavaCompRunner/RawComponent.cpp	Wed Apr 10 09:03:01 2013	(r2170)
@@ -47,6 +47,7 @@
 		//throw hresult_exception(E_FAIL);
 		throw regkey;
 	}
+	classPath[bufSize] = '\0';
 
     RegCloseKey(regkey);
 
@@ -55,14 +56,16 @@
     RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\GME", 0, KEY_EXECUTE, &regkey);
     type = REG_SZ;
     bufSize = sizeof(memory) / sizeof(memory[0]);
-    RegQueryValueEx(regkey, "JavaMemory", NULL, &type, (LPBYTE)memory, &bufSize );
+	if (RegQueryValueEx(regkey, "JavaMemory", NULL, &type, (LPBYTE)memory, &bufSize) == ERROR_SUCCESS)
+		memory[bufSize] = '\0';
     RegCloseKey(regkey);
 
     // query jvm.dll path from registry
     RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\JavaSoft\\Java Runtime Environment", 0, KEY_EXECUTE, &regkey);
     type = REG_SZ;        
 	bufSize = 2000;
-    RegQueryValueEx(regkey, "CurrentVersion", NULL, &type, (LPBYTE)buf, &bufSize );
+	if (RegQueryValueEx(regkey, "CurrentVersion", NULL, &type, (LPBYTE)buf, &bufSize) == ERROR_SUCCESS)
+		buf[bufSize] = '\0';
     RegCloseKey(regkey);
     char javaVersionPath[2000];
     sprintf( javaVersionPath, "SOFTWARE\\JavaSoft\\Java Runtime Environment\\%s", buf );
@@ -70,7 +73,8 @@
     bufSize = 2000;
     type    = REG_SZ;
     buf[0] = 0;
-    RegQueryValueEx(regkey, "RuntimeLib", NULL, &type, (LPBYTE)buf, &bufSize );
+	if (RegQueryValueEx(regkey, "RuntimeLib", NULL, &type, (LPBYTE)buf, &bufSize) == ERROR_SUCCESS)
+		buf[bufSize] = '\0';
     RegCloseKey(regkey);
     if( strlen(buf)==0 )
     {        


More information about the gme-commit mailing list