fix: seed PRNG so code/math challenges change on every ring #1

Merged
johnpreston merged 1 commit from fix/code-challenge-not-random into main 2026-09-17 20:34:57 +00:00
Member

Problem

The dismiss challenge code (4-digit code) and math problem were not actually random — they produced the same value every time.

Root cause

qrand() was called in beginRinging() to generate the challenge, but qsrand() was never called to seed the PRNG. On this Qt (older than 5.7), qrand() defaults to a deterministic seed, so every alarm ring presented the same four-digit code and the same math problem — defeating the entire purpose of the dismiss challenge.

Fix

Seed qrand() with QDateTime::currentMSecsSinceEpoch() before each challenge generation in beginRinging(). Each ringer is a fresh process launched by timed, so per-ring seeding is sufficient and avoids any global init-order dependency (AGENTS.md landmine #7).

Added seeding in both the code and math challenge branches.

Version bumped to 0.0.15 per the build-iteration policy.

Files changed

  • app/src/alarmcontroller.cpp — added qsrand() calls before qrand() usage
  • app/app.pro — version bump 0.0.14 → 0.0.15
  • rpm/harbour-heratys52.spec — version bump 0.0.14 → 0.0.15
## Problem The dismiss challenge code (4-digit code) and math problem were **not actually random** — they produced the same value every time. ## Root cause `qrand()` was called in `beginRinging()` to generate the challenge, but `qsrand()` was **never called** to seed the PRNG. On this Qt (older than 5.7), `qrand()` defaults to a deterministic seed, so every alarm ring presented the same four-digit code and the same math problem — defeating the entire purpose of the dismiss challenge. ## Fix Seed `qrand()` with `QDateTime::currentMSecsSinceEpoch()` before each challenge generation in `beginRinging()`. Each ringer is a fresh process launched by timed, so per-ring seeding is sufficient and avoids any global init-order dependency (AGENTS.md landmine #7). Added seeding in both the `code` and `math` challenge branches. Version bumped to 0.0.15 per the build-iteration policy. ## Files changed - `app/src/alarmcontroller.cpp` — added `qsrand()` calls before `qrand()` usage - `app/app.pro` — version bump 0.0.14 → 0.0.15 - `rpm/harbour-heratys52.spec` — version bump 0.0.14 → 0.0.15
fix: seed PRNG so code/math challenges change on every ring
All checks were successful
Build aarch64 rpm / build (pull_request) Successful in 3m16s
Build aarch64 rpm / build (push) Successful in 3m24s
b9325e02f4
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ews-network/alarmist!1
No description provided.