Skip to content

fix: COM_StripExtension overflow and CG_CompileText heap churn/OOB write#82

Closed
Kr3m wants to merge 1 commit intosnems:masterfrom
Kr3m:bugFixes
Closed

fix: COM_StripExtension overflow and CG_CompileText heap churn/OOB write#82
Kr3m wants to merge 1 commit intosnems:masterfrom
Kr3m:bugFixes

Conversation

@Kr3m
Copy link
Copy Markdown
Contributor

@Kr3m Kr3m commented Apr 11, 2026

Had some crash issues with other mods and thought I'd share my fix.

  • COM_StripExtension: add destsize parameter and reimplement using Q_strncpyz to avoid unbounded copy and undefined in‑place use. Update all cg_weapons.c call sites to pass sizeof(path).

  • CG_CompileText: replace per‑frame Z_Malloc scratch buffers with static arrays; cap input length at MAX_STRING_CHARS; add bounds check (i < OSP_TEXT_CMD_MAX - 1) to prevent command array overrun. CG_CompiledTextDestroy becomes a no‑op.

- COM_StripExtension: add destsize parameter and reimplement using
  Q_strncpyz to avoid unbounded copy and undefined in‑place use.
  Update all cg_weapons.c call sites to pass sizeof(path).

- CG_CompileText: replace per‑frame Z_Malloc scratch buffers with static
  arrays; cap input length at MAX_STRING_CHARS; add bounds check
  (i < OSP_TEXT_CMD_MAX - 1) to prevent command array overrun.
  CG_CompiledTextDestroy becomes a no‑op.
@Kr3m Kr3m closed this Apr 12, 2026
@Kr3m
Copy link
Copy Markdown
Contributor Author

Kr3m commented Apr 12, 2026

I might need to tune this a bit first.

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