Changeset 24384 in vbox
- Timestamp:
- Nov 5, 2009 2:06:22 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuestLib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibHostVersion.cpp
r24357 r24384 24 24 * Header Files * 25 25 *******************************************************************************/ 26 #include <stdlib.h> 27 #include <stdio.h> 26 #include <stdio.h> /* Required for sscanf */ 28 27 #include <iprt/string.h> 29 28 #include <VBox/log.h> … … 114 113 /* Only don't do the check if we have a valid "0" in it */ 115 114 if ( *pszCheckHostVersion 116 && atoi(pszCheckHostVersion) == 0) /** @todo r=bird: don't use atoi, use RTStrToXX. avoid std*.h!*/115 && RTStrToInt16(pszCheckHostVersion) == 0) /* Either string conversion failed or we really did disable it */ 117 116 { 118 117 LogRel(("No host version update check performed (disabled).\n")); -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp
r24372 r24384 238 238 VBGLR3DECL(int) VbglR3GetAdditionsVersion(char **ppszVer, char **ppszRev) 239 239 { 240 # ifdef RT_OS_WINDOWS240 # ifdef RT_OS_WINDOWS 241 241 /* 242 242 * Try get the *installed* version first. 243 243 */ 244 HKEY hKey ;244 HKEY hKey = NULL; 245 245 LONG r; 246 246 … … 272 272 if (r == ERROR_SUCCESS) 273 273 { 274 /** @todo r=bird: If anything fails here, this code will end up returning275 * rc=VINF_SUCCESS and uninitialized output pointers. It will also276 * leak memory in some cases. Iff the value type isn't string,277 * garbage is returned.278 *279 * RTMemAlloc shall be freed by RTMemFree not RTStrFree. Don't ever mix280 * because it will blow up in an annoying way when using the eletrical281 * fences and stuff. Use a temporary buffer and RTStrDupEx.282 */283 274 /* Version. */ 284 275 DWORD dwType; … … 292 283 r = RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)pszTmp, &dwSize); 293 284 if (r == ERROR_SUCCESS) 294 rc = RTStrDupEx(ppszVer, pszTmp); 285 { 286 if (dwType == REG_SZ) 287 rc = RTStrDupEx(ppszVer, pszTmp); 288 else 289 rc = VERR_INVALID_PARAMETER; 290 } 295 291 else 292 { 296 293 rc = RTErrConvertFromNtStatus(r); 294 } 297 295 RTMemFree(pszTmp); 298 296 } … … 309 307 r = RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)pszTmp, &dwSize); 310 308 if (r == ERROR_SUCCESS) 311 rc = RTStrDupEx(ppszRev, pszTmp); 309 { 310 if (dwType == REG_SZ) 311 rc = RTStrDupEx(ppszRev, pszTmp); 312 else 313 rc = VERR_INVALID_PARAMETER; 314 } 312 315 else 316 { 313 317 rc = RTErrConvertFromNtStatus(r); 318 } 314 319 RTMemFree(pszTmp); 315 320 } … … 317 322 rc = VERR_NO_MEMORY; 318 323 } 324 if (hKey != NULL) 325 RegCloseKey(hKey); 319 326 } 320 327 else … … 326 333 rc = vbglR3GetAdditionsCompileTimeVersion(ppszVer, ppszRev); 327 334 } 328 if (hKey != NULL) /** @todo r=bird: This looks kind of wrong for the failure case... */ 329 RegCloseKey(hKey); 330 return rc; 331 332 #else /* !RT_OS_WINDOWS */ 335 return rc; 336 337 # else /* !RT_OS_WINDOWS */ 333 338 /* 334 339 * On non-Windows platforms just return the compile-time version string. 335 340 */ 336 341 return vbglR3GetAdditionsCompileTimeVersion(ppszVer, ppszRev); 337 # endif /* !RT_OS_WINDOWS */338 } 342 # endif /* !RT_OS_WINDOWS */ 343 }
Note:
See TracChangeset
for help on using the changeset viewer.