ABSTRACT

The function is obsolete and cannot guarantee that a pointer is valid or referenced memory is safe to use.

EXPLANATION

There are a number of reasons not to use the IsBadXXXPtr() class of functions. These functions are:
1) Not thread safe.
2) Often implicated in crashes caused by their probing of invalid memory addresses.
3) Erroneously believed to carry out proper error handling during exception conditions.

Example: The following code uses IsBadWritePtr() in an attempt to prevent bad memory writes.


if (IsBadWritePtr(ptr, length))
{
[handle error]
}


Programmers often use these functions intending that they will detect exception cases, but the functions usually cause more problems than they fix.

REFERENCES

[1] Standards Mapping - OWASP Top 10 2004 - (OWASP 2004) A9 Application Denial of Service

[2] Standards Mapping - Security Technical Implementation Guide Version 3 - (STIG 3) APP6080 CAT II

[3] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 730

[4] IsBadWritePtr Function Microsoft

[5] Raymond Chen IsBadXxxPtr should really be called CrashProgramRandomly

[6] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 - (PCI 1.1) Requirement 6.5.9