Reject zero-size operation name buffers#4973
Open
fallintoplace wants to merge 1 commit into
Open
Conversation
Contributor
|
Thank you for your contribution! Since this is an external pull request, a maintainer must review PR and add the "ok-to-test" label if it is approved for testing. |
pfultz2
reviewed
Jun 16, 2026
| p.add_param(t) | ||
| p.add_param('size_t', p.name + '_size') | ||
| p.bad_param('${name} == nullptr', 'Null pointer') | ||
| p.bad_param('${name}_size == 0', 'zero', '${name}_size') |
Collaborator
There was a problem hiding this comment.
An empty string could be a valid input perhaps not in this case, but this makes it always a bad param everytime we take a string as input.
Collaborator
There was a problem hiding this comment.
Ah wait, nevermind, this is for the output parameter not the input.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4973 +/- ##
========================================
Coverage 92.73% 92.74%
========================================
Files 592 592
Lines 31289 31291 +2
========================================
+ Hits 29015 29018 +3
+ Misses 2274 2273 -1
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
migraphx_operation_nameaccepted a non-null output pointer without_size == 0, then computedout_size - 1before copying the operation name. That underflowed the limit used bystd::copy_nand could write past the caller's buffer.This change rejects zero-size output buffers with
migraphx_status_bad_param, updates the API generator so regenerated C API output keeps the same guard, and extends the C API operation-construction test to cover null output, zero size, truncation, and normal success.Tests
git diff --checkpython3 -m py_compile tools/api.py src/api/migraphx.pypython3 tools/api.py src/api/migraphx.py tools/api/api.cpp | rg -n "migraphx_operation_name|Bad parameter out|Bad parameter out_size|copy_n" -C 3cc -fsyntax-only -I <temporary export-header include> -I src/api/include test/api/test_c_op_construct.cNot run: full CMake/API test target. Local configure stops before target generation because
ROCmCMakeBuildToolsis not installed on this machine.