cli: stop applying out-of-range zone size in --size handler#101
Open
jbetala7 wants to merge 1 commit into
Open
cli: stop applying out-of-range zone size in --size handler#101jbetala7 wants to merge 1 commit into
jbetala7 wants to merge 1 commit into
Conversation
OptionSize() validates the requested zone size against the zone's leds_min/leds_max, but unlike the sibling device-out-of-range and zone-out-of-range checks it only printed "Error: New size is out of range" and then fell through, calling ResizeZone(current_zone, new_size) with the rejected value and persisting it via SaveProfile(). Since RGBController::ResizeZone() is a pure-virtual implemented per device, the CLI bounds check is the only general guard, so the bypass forwards an out-of-range size straight to device resize code and saves it to the "sizes" profile. Return false on the out-of-range branch, matching the two preceding validation branches, so an invalid size is neither applied nor saved. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
OptionSize()(the--sizeCLI handler) validates the requested zone size against the zone'sleds_min/leds_max, but the out-of-range branch only prints an error and then falls through — it does not stop like the two sibling validation branches do.So a size that was explicitly rejected as out of range is still passed to
ResizeZone()and then written to thesizesprofile.Why this matters
RGBController::ResizeZone(int zone, int new_size)is pure-virtual and implemented per device, so this CLI bounds check is the only general guard in front of it. Bypassing it forwards an out-of-range size directly to device-specific resize code (which generally trusts the value, e.g. resizing LED vectors) and saves the bad value to the profile, so it is re-applied on the next load.Current behavior (upstream
master)openrgb --device N --zone Z --size <out-of-range>printsError: New size is out of rangeand then resizes the zone to that value anyway and saves it.Expected behavior
An out-of-range size should be rejected without resizing or saving, exactly like the device-out-of-range and zone-out-of-range cases.
Fix
Add the missing
return false;to the out-of-range branch so it matches the two preceding validation branches.else if((new_size < ...leds_min) || (new_size > ...leds_max)) { std::cout << "Error: New size is out of range" << std::endl; + return false; }Verification
Verified by inspection: the change makes the third validation branch structurally identical to the two sibling branches in the same function that already
return false. The buggy fall-through intoResizeZone()+SaveProfile()is removed for rejected sizes; valid sizes are unaffected. (A full runtime test of--sizerequires target RGB hardware, so it was not exercised on real devices.)Duplicate / collision check
No open or recently-closed PR touches
cli.cpp'sOptionSizeor the size-bounds logic (open PRs in the area are device-specific or GUI, e.g. #87 Razer SetupZones, #29 color-picker cursor bounds).🤖 Generated with Claude Code