# US 8,578,343 B2 · System and method for overflow detection using partial evaluations

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 8,578,343 B2
- Document ID: US8578343B2
- Status: Granted
- Kind: B2
- Application number: 12/688,078
- Filed: 2010-01-15
- Published: 2011-07-21
- Granted: 2013-11-05
- Earliest claimed: 2010-01-15
- Assignees: Oracle America, Inc.
- Applicants: Bernhard F. Scholz; Cristina N. Cifuentes; Nathan Robert Albert Keynes
- Inventors: Bernhard F. Scholz; Cristina N. Cifuentes; Nathan Robert Albert Keynes
- Web page: https://patentgrep.com/patent/US8578343B2

## CPC

- G06F 11/3624: {by performing operations on the source code, e.g. via a compiler}
- G06F 11/3612: {by runtime analysis (performance monitoring G06F11/3466)}
- G06F 21/577: {Assessing vulnerabilities and evaluating computer system security}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for overflow detection using partial evaluations. The method includes obtaining a section of code from a source code file stored on a storage device, analyzing the section of code to identify a buffer with an index, determining a plurality of statements that are statically-computable and dependent on the index of the buffer, and generating a code segment including the plurality of statements. The method further includes replacing an access statement of the plurality of statements with a conditional statement returning true when bounds of the buffer are exceeded, where the access statement uses the index to access the buffer, adding an unconditional statement returning false to the code segment, and executing the code segment on a computer processor to obtain a determination of whether the bounds of the buffer are exceeded.

## Claims

### Claim 1

A method for overflow detection using partial evaluations comprising:
obtaining a section of code from a source code file stored on a storage device;
identifying, within the section of code, an access statement to access a buffer;
identifying, within the access statement, an index used to access the buffer, wherein the index is statically-computable;
determining bounds of the buffer;
identifying a plurality of statements that are statically-computable and affect the index;
generating a code segment comprising the plurality of statements and the access statement;
replacing the access statement of the code segment with a conditional statement returning true when the index exceeds the bounds of the buffer;
adding an unconditional statement returning false to the code segment;
adding a bail out conditional statement to the code segment, wherein the bail out conditional statement is configured to interrupt execution of the code segment when a specified number of iterations in the code segment are performed;
executing the code segment on a computer processor to obtain a return value of the code segment; and
determining, based on the return value, that the bounds of the buffer were exceeded during execution of the code segment.

### Claim 2 (depends on 1)

The method of claim 1, wherein identifying the plurality of statements comprises:
applying a plurality of data flow equations to a control flow graph to obtain an updated control flow graph; and
using the updated control flow graph to identify the plurality of statements that are dependent on the index.

### Claim 3 (depends on 2)

The method of claim 2, wherein the control flow graph represents the section of code in single assignment form.

### Claim 4 (depends on 1)

The method of claim 1, wherein a size of the code segment is dependent on a control statement, wherein the plurality of statements comprises the control statement.

### Claim 5 (depends on 1)

The method of claim 1, wherein a size of the buffer is statically computable.

### Claim 6 (depends on 1)

The method of claim 1, wherein the code segment is executed using at least one of a group consisting of interpretation and just-in-time compilation techniques.

### Claim 7

A system for overflow detection using partial evaluations comprising:
a memory; and
a processor operatively connected to the memory and having functionality to execute instructions for:
obtaining a section of code from a source code file stored on a storage device;
identifying, within the section of code, an access statement to access a buffer;
identifying, within the access statement, an index used to access the buffer, wherein the index is statically-computable;
determining bounds of the buffer;
identifying a plurality of statements that are statically-computable and affect the index;
generating a code segment comprising the plurality of statements and the access statement;
replacing the access statement of the code segment with a conditional statement returning true when the index exceeds the bounds of the buffer;
adding an unconditional statement returning false to the code segment;
adding a bail out conditional statement to the code segment, wherein the bail out conditional statement is configured to interrupt execution of the code segment when a specified number of iterations in the code segment are performed;
executing the code segment on a computer processor to obtain a return value of the code segment; and
determining, based on the return value, that the bounds of the buffer were exceeded during execution of the code segment.

### Claim 8 (depends on 7)

The system of claim 7, wherein identifying the plurality of statements comprises:
applying a plurality of data flow equations to a control flow graph to obtain an updated control flow graph; and
using the updated control flow graph to identify the plurality of statements that are dependent on the index.

### Claim 9 (depends on 8)

The system of claim 8, wherein the control flow graph represents the section of code in single assignment form.

### Claim 10 (depends on 7)

The system of claim 7, wherein a size of the code segment is dependent on a control statement, wherein the plurality of statements comprises the control statement.

### Claim 11 (depends on 7)

The system of claim 7, wherein a size of the buffer is statically computable.

### Claim 12 (depends on 7)

The system of claim 7, wherein the code segment is executed using at least one of a group consisting of interpretation and just-in-time compilation techniques.

### Claim 13

A non-transitory computer readable medium storing instructions for overflow detection using partial evaluations, the instructions comprising functionality to:
obtain a section of code from a source code file stored on a storage device;
identify, within the section of code, an access statement to access a buffer;
identify, within the access statement, an index used to access the buffer, wherein the index is statically computable;
determine bounds of the buffer;
identify a plurality of statements that are statically-computable and affect the index;
generate a code segment comprising the plurality of statements and the access statement;
replace the access statement of the code segment with a conditional statement returning true when the index exceeds the bounds of the buffer;
add an unconditional statement returning false to the code segment;
add a bail out conditional statement to the code segment, wherein the bail out conditional statement is configured to interrupt execution of the code segment when a specified number of iterations in the code segment are performed;
execute the code segment on a computer processor to obtain a return value of the code segment; and
determine, based on the return value, that the bounds of the buffer were exceeded during execution of the code segment.

### Claim 14 (depends on 13)

The non-transitory computer readable medium of claim 13, wherein identifying the plurality of statements comprises:
applying a plurality of data flow equations to a control flow graph to obtain an updated control flow graph; and
using the updated control flow graph to identify the plurality of statements that are dependent on the index.

### Claim 15 (depends on 14)

The non-transitory computer readable medium of claim 14, wherein the control flow graph represents the section of code in single assignment form.

### Claim 16 (depends on 13)

The non-transitory computer readable medium of claim 13, wherein a size of the code segment is dependent on a control statement, wherein the plurality of statements comprises the control statement.

### Claim 17 (depends on 13)

The non-transitory computer readable medium of claim 13, wherein a size of the buffer is statically computable.
