VirtualBox

Changeset 46183 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
May 21, 2013 12:26:23 AM (12 years ago)
Author:
vboxsync
Message:

VBoxCredProv: intsafe.h _must_ be included before any vbox includes or you'll get a ton of warnings. Fixed a couple of warnings and adding a overflow check to RTUTF16ToUnicode and noting that the fCopy=true case (which isn't used currently) cannot be correctly implemented.

Location:
trunk/src/VBox/Additions/WINNT/VBoxCredProv
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredProvCredential.cpp

    r40435 r46183  
    2323# define WIN32_NO_STATUS
    2424#endif
     25#include <intsafe.h>
    2526
    2627#include "VBoxCredentialProvider.h"
     
    3536#include <iprt/mem.h>
    3637#include <iprt/string.h>
     38
    3739
    3840
     
    121123 * @param   fCopy                   Whether to just assign or copy the actual buffer
    122124 *                                  contents from source -> dest.
     125 * @todo    r=bird: It appears that fCopy == true is never used, which is
     126 *          fortunate as it (a) doesn't check for there being room in the
     127 *          buffer, (b) terminate the string (which is customary, even if not
     128 *          strictly necessary), and (c) overwrites MaximumLength.
    123129 */
    124130HRESULT
    125131VBoxCredProvCredential::RTUTF16ToUnicode(PUNICODE_STRING pUnicodeDest, PRTUTF16 pwszSource, bool fCopy)
    126132{
    127     AssertPtrReturn(pUnicodeDest, VERR_INVALID_POINTER);
    128     AssertPtrReturn(pwszSource, VERR_INVALID_POINTER);
     133    AssertPtrReturn(pUnicodeDest, E_POINTER);
     134    AssertPtrReturn(pwszSource, E_POINTER);
    129135
    130136    size_t cbLen = RTUtf16Len(pwszSource) * sizeof(RTUTF16);
    131 
    132     pUnicodeDest->Length        = cbLen;
    133     pUnicodeDest->MaximumLength = pUnicodeDest->Length;
     137    AssertReturn(cbLen >= USHORT_MAX, E_INVALIDARG);
     138
     139    pUnicodeDest->Length        = (USHORT)cbLen;
     140    pUnicodeDest->MaximumLength = (USHORT)cbLen;
    134141
    135142    if (fCopy)
     143    {
     144        AssertFailed(/*see todo*/);
    136145        memcpy(pUnicodeDest->Buffer, pwszSource, cbLen);
     146    }
    137147    else /* Just assign the buffer. */
    138148        pUnicodeDest->Buffer    = pwszSource;
     
    602612        &&  pPos != pwszAccountData)
    603613    {
    604         DWORD cbSize = (pPos - pwszAccountData) * sizeof(WCHAR);
     614        size_t cbSize = (pPos - pwszAccountData) * sizeof(WCHAR);
    605615        LPWSTR pwszName = (LPWSTR)CoTaskMemAlloc(cbSize + sizeof(WCHAR)); /* Space for terminating zero. */
    606616        LPWSTR pwszDomain = NULL;
  • trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredProvCredential.h

    r40435 r46183  
    2424*******************************************************************************/
    2525#include <Windows.h>
    26 #include <intsafe.h>
    2726#include <NTSecAPI.h>
    2827#define SECURITY_WIN32
  • trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredentialProvider.h

    r40435 r46183  
    1919#define ___VBOX_CREDENTIALPROVIDER_H___
    2020
    21 #include <windows.h>
     21#include <Windows.h>
    2222#include <credentialprovider.h>
    2323
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