Skip to content

Commit

Permalink
Fixing debuggerVirtualDir path length
Browse files Browse the repository at this point in the history
  • Loading branch information
rramachand21 committed Jun 12, 2014
1 parent f60b3ec commit 643a760
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/iisnode/cmoduleconfiguration.cpp
Expand Up @@ -8,7 +8,7 @@ HTTP_MODULE_ID CModuleConfiguration::moduleId = NULL;
BOOL CModuleConfiguration::invalid = FALSE;

#define EXTENDED_MAX_PATH 32768
#define MAX_HASH_CHAR 32
#define MAX_HASH_CHAR 8

CModuleConfiguration::CModuleConfiguration()
: nodeProcessCommandLine(NULL),
Expand Down Expand Up @@ -1551,9 +1551,9 @@ HRESULT CModuleConfiguration::GetDebuggerFilesPathSegmentHelper(
HCRYPTPROV hProv = 0;
HCRYPTHASH hHash = 0;
CHAR rgbDigits[] = "0123456789abcdef";
BYTE rgbHash[MAX_HASH_CHAR]; // sha256 ==> 32 bytes.
BYTE rgbHash[32]; // sha256 ==> 32 bytes.
DWORD cbHash = 0;
CHAR shaHash[MAX_HASH_CHAR + 1]; // we will only use first 16 bytes of the sha256 hash ==> 32 hex chars.
CHAR shaHash[MAX_HASH_CHAR + 1]; // we will only use first MAX_HASH_CHAR bytes of the sha256 hash ==> 32 hex chars.
DWORD dwSHALength = 0;
CHAR *pInput = NULL;
DWORD dwInputSize = 0;
Expand Down Expand Up @@ -1581,12 +1581,13 @@ HRESULT CModuleConfiguration::GetDebuggerFilesPathSegmentHelper(

ErrorIf(!CryptHashData(hHash, (BYTE*) pInput, strnlen_s(pInput, dwInputSize), 0), HRESULT_FROM_WIN32(GetLastError()));

cbHash = MAX_HASH_CHAR;
// sha256 ==> 32 bytes.
cbHash = 32;
ErrorIf(!CryptGetHashParam(hHash, HP_HASHVAL, rgbHash, &cbHash, 0), HRESULT_FROM_WIN32(GetLastError()));

dwIndex = 0;
// convert first 16 bytes to hexadecimal form.
for (DWORD i = 0; i < 16; i++, dwIndex=dwIndex+2)
// convert first (MAX_HASH_CHAR / 2) bytes to hexadecimal form.
for (DWORD i = 0; i < (MAX_HASH_CHAR / 2); i++, dwIndex=dwIndex+2)
{
shaHash[dwIndex] = rgbDigits[rgbHash[i] >> 4];
shaHash[dwIndex+1] = rgbDigits[rgbHash[i] & 0xf];
Expand Down

0 comments on commit 643a760

Please sign in to comment.