Changeset 95


Ignore:
Timestamp:
1/19/2008 6:58:39 AM (7 years ago)
Author:
lowjoel
Message:

Error checking when querying for elevation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EraserDll/FreeSpace.cpp

    r83 r95  
    225225        HANDLE hToken; 
    226226        TOKEN_ELEVATION_TYPE elevationType; 
    227         DWORD returnSize; 
     227        DWORD returnSize = 0; 
    228228        OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken); 
    229229 
    230230        if (hToken) 
    231231        { 
    232             GetTokenInformation(hToken, TokenElevationType, 
    233                 &elevationType, sizeof(elevationType), &returnSize); 
     232            if (GetTokenInformation(hToken, TokenElevationType, 
     233                &elevationType, sizeof(elevationType), &returnSize)) 
     234            { 
     235                if (elevationType == TokenElevationTypeLimited) 
     236                { 
     237                    context->m_saError.Add("Erasing the Free Space of a drive requires elevation"); 
     238                    return false; 
     239                } 
     240            } 
    234241            CloseHandle(hToken); 
    235             if (elevationType == TokenElevationTypeLimited) { 
    236                 context->m_saError.Add("Erasing the Free Space of a drive requires elevation"); 
    237                 return false; 
    238             } 
    239242        } 
    240243    } 
Note: See TracChangeset for help on using the changeset viewer.