Merge pull request #692 from mfleisz/master

Fixed crash in SamLookupUserW when SamOpen fails in ntlm_fetch_ntlm_v2_hash
This commit is contained in:
Marc-André Moreau 2012-08-10 09:03:15 -07:00
commit 5905d36b46
2 changed files with 22 additions and 20 deletions

View File

@ -226,6 +226,8 @@ void ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, char* hash)
WINPR_SAM_ENTRY* entry;
sam = SamOpen(1);
if (sam == NULL)
return;
entry = SamLookupUserW(sam,
(LPWSTR) context->identity.User, context->identity.UserLength * 2,

View File

@ -33,29 +33,29 @@
WINPR_SAM* SamOpen(BOOL read_only)
{
WINPR_SAM* sam;
FILE* fp = NULL;
WINPR_SAM* sam = NULL;
sam = (WINPR_SAM*) malloc(sizeof(WINPR_SAM));
if (sam != NULL)
if (read_only)
{
sam->read_only = read_only;
if (sam->read_only)
{
sam->fp = fopen(WINPR_SAM_FILE, "r");
}
else
{
sam->fp = fopen(WINPR_SAM_FILE, "r+");
if (!sam->fp)
sam->fp = fopen(WINPR_SAM_FILE, "w+");
}
if (!(sam->fp))
printf("Could not open SAM file!\n");
fp = fopen(WINPR_SAM_FILE, "r");
}
else
{
fp = fopen(WINPR_SAM_FILE, "r+");
if (!fp)
fp = fopen(WINPR_SAM_FILE, "w+");
}
if (fp)
{
sam = (WINPR_SAM*) malloc(sizeof(WINPR_SAM));
sam->read_only = read_only;
sam->fp = fp;
}
else
printf("Could not open SAM file!\n");
return sam;
}