FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/cpp/ql/src/Critical/SizeCheck2.qhelp at codeql-cli/v2.25.3 · github/codeql · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10k
Code
Issues
998
Pull requests
461
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
cpp
/
ql
/
src
/
Critical
/
SizeCheck2.qhelp
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (25 loc) · 1.24 KB
Breadcrumbs
codeql
/
cpp
/
ql
/
src
/
Critical
/
SizeCheck2.qhelp
Copy path
File metadata and controls
31 lines (25 loc) · 1.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!
DOCTYPE
qhelp
PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<
qhelp
>
<
overview
>
<
p
>When you allocate an array from memory using <
code
>malloc</
code
>, <
code
>calloc</
code
> or
<
code
>realloc</
code
>, you should ensure that you allocate enough memory to contain a
multiple of the size of the required pointer type. Calls that are assigned to a non-void
pointer variable, but do not allocate enough memory will cause a buffer overflow when a
field accessed on the pointer points to memory that is beyond the allocated array. Buffer
overflows can lead to anything from a segmentation fault to a security vulnerability.</
p
>
</
overview
>
<
recommendation
>
<
p
>
The highlighted call allocates memory that is not a multiple of the size of the pointer
type, which can cause a memory overrun. Use the <
code
>sizeof</
code
> operator to ensure that the function call allocates enough memory for that type.
</
p
>
</
recommendation
>
<
example
><
sample
src
=
"
SizeCheck2.cpp
"
/>
</
example
>
<
references
>
<
li
>I. Gerg. <
em
>An Overview and Example of the Buffer-Overflow Exploit</
em
>. IANewsletter vol 7 no 4. 2005.</
li
>
<
li
>M. Donaldson. <
em
>Inside the Buffer Overflow Attack: Mechanism, Method
&
Prevention</
em
>. SANS Institute InfoSec Reading Room. 2002.</
li
>
</
references
>
</
qhelp
>
Back
|
FazBrowse Home
|
New Git URL