CWE-242¶
Use of Inherently Dangerous Function. [Api-Function-Errors, Improper-Adherence-To-Coding-Standards]
Required inputs: IR
Demonstrative Examples
Example 1
The code below calls gets() to read information into a buffer.
Example Language:C
char buf[BUFSIZE];
gets(buf);
The gets() function in C is inherently unsafe.
Example 2
The code below calls the gets() function to read in data from the command line.
Example Language:C
char buf[24];
printf("Please enter your name and press <Enter>\n");
gets(buf);
...
}
However, gets() is inherently unsafe, because it copies all input from STDIN to the buffer without checking size. This allows the user to provide a string that is larger than the buffer size, resulting in an overflow condition.
Excerpts from CWE [https://cwe.mitre.org], Copyright (C) 2006-2026, the MITRE Corporation. See section 9.4. "3rd-Party Licenses" in the documentation for full details.Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
forbidden_libfunc_call |
Call to forbidden function. |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
blacklist¶
blacklist
Dictionary of header globbing to (list of) function name globbing(s) of forbidden functions.Type: dict[bauhaus.analysis.config.FileGlobPattern, list[bauhaus.analysis.config.GlobPattern]]
Default:
{ '*stdio.h': ['gets'], 'io.h': ['vfork'], 'unistd.h': ['vfork'] }