Apply suggestions from code review

Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
This commit is contained in:
ihsinme
2021-01-26 23:47:07 +03:00
committed by GitHub
parent b899229298
commit de0bbc8826
2 changed files with 3 additions and 4 deletions

View File

@@ -17,7 +17,7 @@ If terminal zero is present, then the specified expression is meaningless.</p>
</recommendation>
<example>
<p>The following example demonstrates an erroneous and corrected use of the strlen function.</p>
<sample src="AccessOfMemoryLocationAfterEndOfBuffer.c" />
<sample src="AccessOfMemoryLocationAfterEndOfBufferUsingStrlen.c" />
</example>
<references>

View File

@@ -1,8 +1,7 @@
/**
* @name Access Of Memory Location After End Of Buffer
* @description --The expression buffer [strlen (buffer)] = 0 is potentially dangerous, if the variable buffer does not have a terminal zero, then access beyond the bounds of the allocated memory is possible, which will lead to undefined behavior.
* --If terminal zero is present, then the specified expression is meaningless.
* --We recommend using another method for calculating the string length.
* @description The expression `buffer [strlen (buffer)] = 0` is potentially dangerous, if the variable `buffer` does not have a terminal zero, then access beyond the bounds of the allocated memory is possible, which will lead to undefined behavior.
* If terminal zero is present, then the specified expression is meaningless.
* @kind problem
* @id cpp/access-memory-location-after-end-buffer
* @problem.severity warning