Refuse malformed widget formation before desktop projection (by Codex)

This commit is contained in:
Codex committed 2026-11-02 17:47:49 +01:00
1 parent acdc7d5c14
commit fcb6ac14bb
2 files changed
+22 -3

No files matched your search

+5
View File
@@ -5626,6 +5626,11 @@ bool CareerSession::dispatch_desk_widget(const ui::DeskRequest& request, uint64_
identity.stable_club_identity = int(g_.club_ids[size_t(identity.runtime_club)]);
}
if (!validate_desk_setting_owner(identity, revision, error, false)) return false;
// Refuse malformed saved formation state before projecting widget ownership.
// The desktop renderer cannot project indices outside the stored 0..8 range.
if (g_.manager_options[size_t(active) * 5] > 8) {
error = "invalid_saved_formation_automation"; return false;
}
const bool price = request.kind == ui::DeskRequestKind::change_ticket_price;
if (!price && request.kind != ui::DeskRequestKind::change_option) {
error = "unsupported_desk_widget"; return false;
+17 -3
View File
@@ -2670,9 +2670,14 @@ void check_desk_widgets_for_frame(const std::filesystem::path& data, bool framed
const auto before_records = game.manager_records;
const auto before_options = game.manager_options;
const auto before_revision = revision;
const auto before_native = save_stream(game);
const auto before_game = session->game(); const auto before_rand = session->rand();
check(!session->dispatch_desk_widget(request, revision, error) &&
game.manager_records == before_records && game.manager_options == before_options &&
revision == before_revision, "invalid desk widget rejects before all state mutation");
save_stream(game) == before_native && revision == before_revision &&
session->game().seed() == before_game.seed() && session->game().calls() == before_game.calls() &&
session->rand().seed() == before_rand.seed() && session->rand().calls() == before_rand.calls(),
"invalid desk widget rejects before native, revision or RNG mutation");
};
DeskRequest request{DeskRequestKind::change_option, 0, 2, 64, 1, revision};
for (int variant = 0; variant < 7; ++variant) {
@@ -2690,8 +2695,17 @@ void check_desk_widgets_for_frame(const std::filesystem::path& data, bool framed
game.memory.set16(::bmh::layout::Desktops + 2 * 16, 20 | 0x1000);
unchanged(request);
game.memory.set16(::bmh::layout::Desktops + 2 * 16, 20);
game.manager_options[0] = 9;
request.value = 0; unchanged(request);
for(uint8_t invalid_formation : {uint8_t(9),uint8_t(255)}) {
game.manager_options[0] = invalid_formation;
for(int index : {0,1}) {
request.value = index; unchanged(request);
check(error == "invalid_saved_formation_automation",
"malformed formation returns an explicit refusal before desktop projection");
}
unchanged(DeskRequest{DeskRequestKind::change_ticket_price,0,1,55,10,revision});
check(error == "invalid_saved_formation_automation",
"admission dispatch also refuses an unprojectable saved formation atomically");
}
game.manager_options[0] = 0;
// National coaches keep lineup/attitude/marking automation, while admission
// and training controls are unavailable in legacy routine/legacy routine.