Commit 95931fcd authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Fix a buffer overflow in environment variable expansion.

parent 5784c80b
......@@ -1321,7 +1321,7 @@ static void add_dynamic_environment( WCHAR **env, SIZE_T *pos, SIZE_T *size )
static WCHAR *expand_value( WCHAR *env, SIZE_T size, const WCHAR *src, SIZE_T src_len )
{
SIZE_T len, retlen = src_len, count = 0;
SIZE_T len, retlen = src_len + 1, count = 0;
const WCHAR *var;
WCHAR *ret;
......@@ -1364,7 +1364,7 @@ static WCHAR *expand_value( WCHAR *env, SIZE_T size, const WCHAR *src, SIZE_T sr
}
if (len >= retlen - count)
{
retlen *= 2;
retlen = max( retlen * 2, count + len + 1 );
ret = realloc( ret, retlen * sizeof(WCHAR) );
}
memcpy( ret + count, var, len * sizeof(WCHAR) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment