Skip to content

Commit 0283fd3

Browse files
committed
Merge pull request #41 from rob100/variadic_functions
Do not define a variadic function
2 parents ac40acb + 4a3abb8 commit 0283fd3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

04-Considering_Safety.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ Additionally the C++ cast style is more visible and has the possibility to searc
134134

135135
But consider refactoring of program logic (for example, additional checking on overflow and underflow) if you need to cast `double` to `int`. Measure three times and cut 0.9999999999981 times.
136136

137+
## Do not define a variadic function
138+
Variadic functions can accept a variable number of parameters. The probably best known example is printf(). You have the possibility to define this kind of functions by yourself but this is a possible security risk. The usage of variadic functions is not type safe and the wrong input parameters can cause a program termination with an undefined behavior. This undefined behavior can be exploited to a security problem.
139+
If you have the possibility to use a compiler that supports C++11, you can use variadic templates instead.
140+
137141
## Additional Resources
138142

139143
[How to Prevent The Next Heartbleed](http://www.dwheeler.com/essays/heartbleed.html) by David Wheeler is a good analysis of the current state of code safety and how to ensure safe code.

0 commit comments

Comments
 (0)