Skip to content

Validate server retrieval bounds and add regression tests - #34

Merged
adamdickmeiss merged 1 commit into
masterfrom
yaz-server-bounds-checking
Nov 9, 2026
Merged

adamdickmeiss merged 1 commit into
masterfrom
yaz-server-bounds-checking

Conversation

@adamdickmeiss

Copy link
Copy Markdown
Contributor

Limit Present and piggyback retrieval to 10,000 records. Validate counts and start positions before narrowing to int, avoid overflow in range checks, and return failure status with rejection diagnostics.

Add a yaz/test.h server test covering search, retrieval, record contents, piggyback behavior, and invalid bounds. Register it with make check.

Refine ignore patterns for test binaries and generated test results, and remove trailing whitespace.

Validation: all src tests pass, including the new test under UBSan.

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.

🟡 Changes recommended

The >= check rejects valid requests when start plus count equals INT_MAX; it should use > and include a regression test confirming that boundary succeeds.

1 open issue
What changed in this PR

This PR hardens server retrieval bounds in yazpp and adds regression tests for Present and piggyback retrieval.

Changes:

  • Limit retrieval to 10,000 records and validate bounds before integer conversion, returning failure diagnostics for rejected requests.
  • Add server tests for record contents, retrieval behavior, and invalid bounds, registered with make check.
  • Refine test artifact ignore patterns and remove trailing whitespace.
File Description
src/​yaz-z-server-sr.cpp Add retrieval limits, bounds validation, and rejection diagnostics.
src/​test_server.cpp Add server search and retrieval regression tests.
src/​test_gdu.cpp Remove trailing whitespace in the copyright comment.
src/​Makefile.am Register the new server test.
src/​.gitignore Narrow test binary patterns and ignore generated test results.
include/​yazpp/​z-server.h Remove trailing whitespace in the copyright comment.

Review effort: Balanced

Comment thread src/yaz-z-server-sr.cpp Resolved
@adamdickmeiss
adamdickmeiss force-pushed the yaz-server-bounds-checking branch 2 times, most recently from a980ee1 to 0f8ed58 Compare November 9, 2026 19:22
@adamdickmeiss
adamdickmeiss requested a balanced review from Copilot November 9, 2026 19:23

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.

🟡 Changes recommended

A negative mediumSetPresentNumber still reaches the no-retrieval path without a diagnostic, so invalid piggyback counts must be routed through the failure-diagnostic branch.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread src/yaz-z-server-sr.cpp Resolved
@adamdickmeiss
adamdickmeiss force-pushed the yaz-server-bounds-checking branch from 0f8ed58 to bea4411 Compare November 9, 2026 19:30
Limit Present and piggyback retrieval to 10,000 records. Validate
counts and start positions before narrowing to int, avoid overflow
in range checks, and return failure status with rejection diagnostics.
Allow requests whose start plus count equals INT_MAX.

Add a yaz/test.h server test covering search, retrieval, record
contents, piggyback behavior, invalid bounds, and the INT_MAX equality
boundary. Register it with make check.

Use odr_booldup and odr_intdup for allocation and initialization.
Replace numeric diagnostics with named Bib-1 definitions.

Refine ignore patterns for test binaries and generated test results,
and remove trailing whitespace.

Validation: all three src tests pass.

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.

🟢 Approval recommended

The supplied review evidence identifies no active issues requiring resolution.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@adamdickmeiss
adamdickmeiss merged commit fd19541 into master Nov 9, 2026
3 checks passed
@adamdickmeiss
adamdickmeiss deleted the yaz-server-bounds-checking branch November 9, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants