snd8f: fix the crash entering FX: nav_list's buffer 16 -> NAV_MAX 24 (TAPE made FX's chain 17 pages: a stack overrun)

The owner's crash screen (v0.9.9-snd8, PC in foot_crumbs, VEC 1) on pressing
FX: nav_groups / nav_page_list kept the chain's entries in uint8_t v[16];
snd8b's TAPE made FX's chain 17 long. Reproduced under ASan on the host (any
engine), gone with NAV_MAX 24; ui_test checks every chain against it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
This commit is contained in:
Claude committed 2026-10-25 13:18:40 +00:00
1 parent 4976a311b3
commit 07cfaf749e
2 files changed
+11 -3

No files matched your search

+6 -3
View File
@@ -172,7 +172,10 @@ static uint32_t save_level(void) { return nav_lv(); }
static uint32_t home_level(void) { return gen_on() ? 2u : ui.hlv ? 1u : 0u; }
static uint32_t home_set(void) { return ui.hset[home_level() & 1u] & 1u; }
static int home_macros(void) { return ui.home && !ui.menu && !gen_on() && home_set(); } /* MACROS / ROUTES: M1..M4 */
/* the entries shown now (on this track, at this LOAD), in order: their indices in v; how many */
/* the entries shown now (on this track, at this LOAD), in order: their indices in v (NAV_MAX at most: the longest chain,
* FX's 17 since snd8's TAPE, fits: ui_test checks every chain against it; snd8b's 17th page overran a 16 and crashed
* FX); how many */
#define NAV_MAX 24u
static uint32_t nav_list(uint32_t sec, uint8_t *v)
{
const ch_t *c = nav_ch(sec);
@@ -260,7 +263,7 @@ static void nav_button(uint32_t sec)
/* rule 1: SELECT, s detents along the chain (no wrap) */
static void nav_select(int32_t s)
{
uint8_t v[16];
uint8_t v[NAV_MAX];
uint32_t sec = nav_sec(), n = nav_list(sec, v), e = nav_cur(), i;
int32_t at = -1, to;
for (i = 0; i < n; i++)
@@ -286,7 +289,7 @@ static void nav_jump(uint32_t sec, int32_t s)
* one's pages (cnt) and chain index of the first (first); the chain's place *i of *m */
static uint32_t nav_groups(uint8_t *cnt, uint8_t *gi, uint32_t *g, uint32_t *p, uint32_t *i, uint32_t *m)
{
uint8_t v[16];
uint8_t v[NAV_MAX];
uint32_t sec = nav_sec(), n = nav_list(sec, v), e = nav_cur(), k, ng = 0, last = 0xFFu;
const ch_t *c = nav_ch(sec);
*g = *p = *i = 0;
+5
View File
@@ -11517,6 +11517,11 @@ static int test_lz_glo(void)
press(B_GLO); frame();
ok &= str_eq(cur_page()->title, "SYSTEM");
bad += check("0.9.2 GLO: MIXER SENDS GLOBAL SYSTEM (seq2f: COMPS COMPS 2) by SELECT, a GLO tap the next group; from elsewhere the page left", ok);
{ /* (0.9.9-snd8b) every chain fits nav_list's buffer (FX's 17th page, TAPE, overran a 16: a crash entering FX) */
uint32_t k, worst = 0;
for (k = 0; k < NELEM(CHAINS); k++) worst = CHAINS[k].n > worst ? CHAINS[k].n : worst;
bad += check(" every page chain fits nav_list's NAV_MAX (the longest: FX's)", worst <= NAV_MAX);
}
{ /* (0.9.9-snd8) MIXER: ALGORITHM to another track redraws only what changed (no forced frame: it blanked the faders
* first, a flash at each track); the screen then equals a full redraw of the same state */
static uint16_t lazy[240 * 240];