mirror of
https://github.com/reactos/reactos.git
synced 2025-06-28 22:39:42 +00:00
[UCRT] Import Microsoft.Windows.SDK.CRTSource version 10.0.22621.3
Imported from https://www.nuget.org/packages/Microsoft.Windows.SDK.CRTSource/10.0.22621.3 License: MIT
This commit is contained in:
parent
f1b60c66f0
commit
04e0dc4a7a
568 changed files with 115483 additions and 0 deletions
35
sdk/lib/ucrt/stdio/printf_count_output.cpp
Normal file
35
sdk/lib/ucrt/stdio/printf_count_output.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// printf_count_output.cpp
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Defines the functions that control the enable state of %n.
|
||||
//
|
||||
#include <corecrt_internal_stdio.h>
|
||||
|
||||
|
||||
|
||||
static UINT_PTR enable_percent_n = 0;
|
||||
|
||||
|
||||
|
||||
// Enables or disables the %n format specifier for the printf family of functions.
|
||||
// Note the use of the __security_cookie: if the static variable was set to a
|
||||
// known value, an attacker could potentially modify that value and then provide
|
||||
// a malicious %n specifier. The cookie is or'ed with 1 becuase a cookie with a
|
||||
// value of zero is possible.
|
||||
extern "C" int __cdecl _set_printf_count_output(int const value)
|
||||
{
|
||||
int const old = (enable_percent_n == (__security_cookie | 1));
|
||||
enable_percent_n = (value ? (__security_cookie | 1) : 0);
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Tests whether the %n format specifier for the printf family of functions is
|
||||
// enabled.
|
||||
extern "C" int __cdecl _get_printf_count_output()
|
||||
{
|
||||
return enable_percent_n == (__security_cookie | 1);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue