Skip to content

Ignore out-of-range days and hours in price modifiers - #1329

Merged
gskjold merged 1 commit into
mainfrom
fix/price-modifier-export-buffers
Dec 4, 2026
Merged

gskjold merged 1 commit into
mainfrom
fix/price-modifier-export-buffers

Conversation

@gskjold

@gskjold gskjold commented Nov 23, 2026

Copy link
Copy Markdown
Member

Why

/save builds the price modifier day and hour masks straight from the form values (pc.days |= 1 << day, pc.hours |= 1 << hour) without checking the range. This causes two problems:

  • Bits outside the week and the day: day 7, or hours 24–31, set bits that don't belong to any day or hour. Values of 32 or more shift past the width of int, which is undefined behaviour.
  • Export buffer overflow: with such a bit set, the "all days" (0x7F) or "all hours" (0xFFFFFF) shortcut no longer applies. The configuration file export then writes all 7 days or all 24 hours. That is 21 or 72 characters plus the terminator, which is one byte past the end of days[3*7] or hours[3*24] on the stack.

Changes

  • Only accept days 0–6 and hours 0–23 when saving.
  • Size both export buffers for the terminator.

Verification

  • pio run for esp8266dev, esp32dev and esp32s2dev.
  • Not tested on a device.

🤖 Generated with Claude Code

/save set price modifier day and hour bits straight from the form values, so
day 7 or hour 24 to 31 set bits outside the week and the day (and 32 or more
shifted past the width of the int). The configuration file export then wrote
one byte past the end of its days[21] or hours[72] buffer, because a full set
of entries plus the terminator needs one more byte.

- Only accept days 0-6 and hours 0-23 when saving.
- Size both export buffers for the terminator.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

🔧 PR Build Artifacts

Version: bd8b0ef

All environments built successfully. Download the zip files:

Artifacts expire after 7 days. View workflow run

@gskjold gskjold added this to the v2.6.1 milestone Nov 26, 2026
@gskjold
gskjold merged commit 4aab165 into main Dec 4, 2026
8 checks passed
@gskjold
gskjold deleted the fix/price-modifier-export-buffers branch December 4, 2026 09:12
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.

1 participant