Skip to content

Commit

Permalink
Merge pull request #14 from Azure/iisnode-dev
Browse files Browse the repository at this point in the history
Some fixes
  • Loading branch information
rramachand21 committed Jul 14, 2014
2 parents b603c7a + 2b95923 commit afb5f7c
Show file tree
Hide file tree
Showing 7 changed files with 2,279 additions and 2,156 deletions.
13 changes: 7 additions & 6 deletions src/iisnode/cmoduleconfiguration.cpp
Original file line number Diff line number Diff line change
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
39 changes: 39 additions & 0 deletions src/iisnode/cnodeconstants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef __CNODECONSTATNTS_H__
#define __CNODECONSTATNTS_H__

class CNodeConstants
{
public:
enum SubStatusCodes500
{
IISNODE_ERROR_ON_EXECUTE_REQ_HANDLER = 1000,
IISNODE_ERROR_PIPE_CONNECTION = 1001,
IISNODE_ERROR_PIPE_CONNECTION_BEFORE_PROCESS_TERMINATED = 1002,
IISNODE_ERROR_CONFIGURE_PIPE_CONNECTION = 1003,
IISNODE_ERROR_FAILED_INIT_SEND_HTTP_HEADERS = 1004,
IISNODE_ERROR_FAILED_SERIALIZE_HTTP_HEADERS = 1005,
IISNODE_ERROR_FAILED_SEND_HTTP_HEADERS = 1006,
IISNODE_ERROR_FAILED_READ_REQ_BODY = 1007,
IISNODE_ERROR_FAILED_READ_REQ_BODY_COMPLETED = 1008,
IISNODE_ERROR_FAILED_INIT_SEND_REQ_BODY = 1009,
IISNODE_ERROR_FAILED_SEND_REQ_BODY = 1010,
IISNODE_ERROR_FAILED_INIT_READ_RESPONSE = 1011,
IISNODE_ERROR_FAILED_ALLOC_MEM_READ_RESPONSE = 1012,
IISNODE_ERROR_FAILED_PROCESS_HTTP_STATUS_LINE = 1013,
IISNODE_ERROR_FAILED_PROCESS_HTTP_HEADERS = 1014,
IISNODE_ERROR_FAILED_PROCESS_RESPONSE_BODY_CHUNK_HEADER = 1015,
IISNODE_ERROR_FAILED_SEND_RESPONSE_BODY_CHUNK = 1016,
IISNODE_ERROR_FAILED_FLUSH_RESPONSE_BODY = 1017,
IISNODE_ERROR_FAILED_FLUSH_RESPONSE_BODY_PARTIAL_FLUSH = 1018
};

enum SubStatusCodes503
{
IISNODE_ERROR_NOT_ENOUGH_QUOTA = 1000,
IISNODE_ERROR_FAILED_ACCEPT_REQUEST_APP_RECYCLE = 1001,
IISNODE_ERROR_INIT_PROCESS_REQUEST = 1002,
IISNODE_ERROR_PIPE_CONNECTION_TOO_BUSY = 1003
};
};

#endif
Loading

0 comments on commit afb5f7c

Please sign in to comment.