Skip to content

Add length check in Doc::data_len()#13133

Open
masaori335 wants to merge 1 commit into
apache:masterfrom
masaori335:asf-master-fix-cache-doc
Open

Add length check in Doc::data_len()#13133
masaori335 wants to merge 1 commit into
apache:masterfrom
masaori335:asf-master-fix-cache-doc

Conversation

@masaori335
Copy link
Copy Markdown
Contributor

To avoid underflow.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a defensive length check to Doc::data_len() in the cache layer so malformed Doc::len / hlen combinations no longer underflow when computing payload length.

Changes:

  • Add a guard in Doc::data_len() to return 0 when the fragment length is not large enough to contain the Doc prefix plus header.
  • Preserve the existing payload-length computation for valid cache documents.

Comment thread src/iocore/cache/P_CacheDoc.h
Comment thread src/iocore/cache/P_CacheDoc.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants