GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — codeql/cpp/ql/src/Critical/SizeCheck2.qhelp at codeql-cli/v2.25.2 · github/codeql

Expand file tree

/

SizeCheck2.qhelp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
31 lines (25 loc) · 1.24 KB
/

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 &amp; Prevention</em>. SANS Institute InfoSec Reading Room. 2002.</li>
</references>
</qhelp>
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.