Skip to content

Array Bounds check for FDR Engine Array - #473

Closed
keerthimuvva52 wants to merge 2 commits into
masterfrom
ArrayBoundFdr
Closed

Array Bounds check for FDR Engine Array#473
keerthimuvva52 wants to merge 2 commits into
masterfrom
ArrayBoundFdr

Conversation

@keerthimuvva52

Copy link
Copy Markdown

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds defense-in-depth validation to prevent out-of-bounds access when executing FDR engines by ensuring engineID values used to index the FDR dispatch table are within bounds.

Changes:

  • Introduces FDR_ENGINE_COUNT as the serialized upper bound for valid FDR engineID values.
  • Adds runtime bounds checks in fdrExec() / fdrExecStreaming() before indexing the funcs[] dispatch table.
  • Adds database-load-time validation to reject databases containing invalid FDR engineID values reachable from the RoseEngine.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/fdr/fdr.h Defines FDR_ENGINE_COUNT to constrain serialized engineID values.
src/fdr/fdr.c Adds engineID bounds checks before indexing the FDR dispatch table.
src/database.c Validates FDR engineID values while validating Rose/HWLM offsets to reject forged DBs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/fdr/fdr.h
Comment on lines +39 to +41
/** Number of entries in the fdrExec dispatch table (funcs[]). Any serialized
* FDR engineID must be strictly less than this value. */
#define FDR_ENGINE_COUNT 19
Comment thread src/fdr/fdr.c
Comment on lines +848 to +851
assert(fdr->engineID < ARRAY_LENGTH(funcs));
if (unlikely(fdr->engineID >= ARRAY_LENGTH(funcs))) {
return HWLM_SUCCESS; /* reject: forged engineID */
}
Comment thread src/fdr/fdr.c
if (unlikely(a.start_offset >= a.len)) {
ret = HWLM_SUCCESS;
} else {
assert(fdr->engineID < ARRAY_LENGTH(funcs));
Comment thread src/database.c
Comment on lines +307 to +311
if (unlikely(off >= rose_size ||
off + sizeof(struct HWLM) > rose_size)) {
DEBUG_PRINTF("HWLM matcher offset %u out of bounds\n", off);
return HS_INVALID;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants