Skip to content

Commit 52719b5

Browse files
committed
[VCRUNTIME] Fix a bug in x64 __security_init_cookie
1 parent 182f353 commit 52719b5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sdk/lib/vcruntime/__security_init_cookie.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,17 @@ void __security_init_cookie(void)
7070
randomValue += GetCurrentProcessId();
7171
randomValue = _rotlptr(randomValue, GetCurrentProcessId() >> 2);
7272

73-
if (randomValue == DEFAULT_SECURITY_COOKIE)
74-
{
75-
randomValue++;
76-
}
77-
7873
#ifdef _WIN64
7974
/* Zero out highest 16 bits */
8075
randomValue &= 0x0000FFFFFFFFFFFFull;
8176
#endif
8277

78+
/* Avoid the default security cookie */
79+
if (randomValue == DEFAULT_SECURITY_COOKIE)
80+
{
81+
randomValue++;
82+
}
83+
8384
__security_cookie = randomValue;
8485
__security_cookie_complement = ~randomValue;
8586
}

0 commit comments

Comments
 (0)