Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix memory leak in ntlm_nt_hash() error paths
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Feb 28, 2015
1 parent d9f611b commit 758411c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ntlm.c
Expand Up @@ -773,23 +773,24 @@ static int ntlm_nt_hash (const char *pass, char hash[21])
to the next multiple of 64. */
ret = buf_ensure_space(utf16pass, ((strlen(pass) * 2) + 1 + 8 + 63) & ~63);
if (ret)
return ret;
goto out;

ret = buf_append_utf16le(utf16pass, pass);
if (ret < 0)
return ret;
goto wipe;

ret = buf_error(utf16pass);
if (ret)
return ret;
goto wipe;

ret = md4sum(utf16pass, (unsigned char *) hash);
if (ret)
return ret;

memset (hash + 16, 0, 5);
goto wipe;

memset(hash + 16, 0, 5);
wipe:
memset(utf16pass->data, 0, utf16pass->pos);
out:
buf_free(utf16pass);
return 0;
}
Expand Down

0 comments on commit 758411c

Please sign in to comment.