VirtualBox

Changeset 24384 in vbox


Ignore:
Timestamp:
Nov 5, 2009 2:06:22 PM (15 years ago)
Author:
vboxsync
Message:

VbglR3: Various fixes based on review.

Location:
trunk/src/VBox/Additions/common/VBoxGuestLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibHostVersion.cpp

    r24357 r24384  
    2424*   Header Files                                                               *
    2525*******************************************************************************/
    26 #include <stdlib.h>
    27 #include <stdio.h>
     26#include <stdio.h>          /* Required for sscanf */
    2827#include <iprt/string.h>
    2928#include <VBox/log.h>
     
    114113        /* Only don't do the check if we have a valid "0" in it */
    115114        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 */
    117116        {
    118117            LogRel(("No host version update check performed (disabled).\n"));
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp

    r24372 r24384  
    238238VBGLR3DECL(int) VbglR3GetAdditionsVersion(char **ppszVer, char **ppszRev)
    239239{
    240 #ifdef RT_OS_WINDOWS
     240# ifdef RT_OS_WINDOWS
    241241    /*
    242242     * Try get the *installed* version first.
    243243     */
    244     HKEY hKey;
     244    HKEY hKey = NULL;
    245245    LONG r;
    246246
     
    272272    if (r == ERROR_SUCCESS)
    273273    {
    274 /** @todo r=bird: If anything fails here, this code will end up returning
    275  *        rc=VINF_SUCCESS and uninitialized output pointers.  It will also
    276  *        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 mix
    280  *        because it will blow up in an annoying way when using the eletrical
    281  *        fences and stuff.  Use a temporary buffer and RTStrDupEx.
    282  */
    283274        /* Version. */
    284275        DWORD dwType;
     
    292283                r = RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)pszTmp, &dwSize);
    293284                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                }
    295291                else
     292                {
    296293                    rc = RTErrConvertFromNtStatus(r);
     294                }
    297295                RTMemFree(pszTmp);
    298296            }
     
    309307                r = RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)pszTmp, &dwSize);
    310308                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                }
    312315                else
     316                {
    313317                    rc = RTErrConvertFromNtStatus(r);
     318                }
    314319                RTMemFree(pszTmp);
    315320            }
     
    317322                rc = VERR_NO_MEMORY;
    318323        }
     324        if (hKey != NULL)
     325            RegCloseKey(hKey);
    319326    }
    320327    else
     
    326333        rc = vbglR3GetAdditionsCompileTimeVersion(ppszVer, ppszRev);
    327334    }
    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 */
    333338    /*
    334339     * On non-Windows platforms just return the compile-time version string.
    335340     */
    336341    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.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette