New Published Rules - dannytheway_personal.unbounded-copy-to-stack-buffer#3781
New Published Rules - dannytheway_personal.unbounded-copy-to-stack-buffer#3781semgrep-dev-pr-bot[bot] wants to merge 2 commits intodevelopfrom
Conversation
| void foo() { | ||
| char buf[64]; | ||
| // ruleid: unbounded-copy-to-stack-buffer | ||
| gets(buf); |
There was a problem hiding this comment.
Semgrep identified an issue in your code:
The gets() function reads a line from stdin into the provided buffer
until either a terminating newline or EOF. This terminating newline or
EOF is replaced with a null byte '\0'. No check for buffer overruns are
performed so it is recommended to use fgets() instead. Do note
that some platforms will continue reading data after a '\0' is encountered.
Usage of fgets() is not recommended for reading binary based files or inputs,
instead the read or fread functions should be used.
For more information please see: https://linux.die.net/man/3/fgets
To resolve this comment:
🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by _getts-1.
You can view more details about this finding in the Semgrep AppSec Platform.
| void test_001() { | ||
| char buf[BUFFER_SIZE]; | ||
| // ruleid: unbounded-copy-to-stack-buffer | ||
| if (gets(buf) == NULL) { |
There was a problem hiding this comment.
Semgrep identified an issue in your code:
The gets() function reads a line from stdin into the provided buffer
until either a terminating newline or EOF. This terminating newline or
EOF is replaced with a null byte '\0'. No check for buffer overruns are
performed so it is recommended to use fgets() instead. Do note
that some platforms will continue reading data after a '\0' is encountered.
Usage of fgets() is not recommended for reading binary based files or inputs,
instead the read or fread functions should be used.
For more information please see: https://linux.die.net/man/3/fgets
To resolve this comment:
🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by _getts-1.
You can view more details about this finding in the Semgrep AppSec Platform.
|
Semgrep found 17
The function |
Wahoo! New published rules with
dannytheway_personal.unbounded-copy-to-stack-bufferfrom @dannytheway.See semgrep.dev/s/boL4Z for more details.
Thanks for your contribution! ❤️