Commit graph

8 commits

Author SHA1 Message Date
Stephen Dennis
6b2e1bf753 nls: convert remaining count plurals to MN_() (#1661)
Three player-visible notify sites still computed English morphology in C
and passed it as %s — the #1622 shape:

  %d queue entr%s removed.          y / ies   (cque, two sites)
  %d orphaned attribute name%s purged.  "" / s  (@dbclean)

MN_(singular, plural, n) sends the count to the catalogue.  Regenerates
the pot and fills xx.po; ko.po leaves the new entries untranslated.
2026-07-28 05:12:03 +00:00
Stephen Dennis
7dea5b97ce nls: mark remaining small engine notify piles with M_ (#1419)
Sweep the leftover constant notify/raw_notify sites outside the large
already-sliced files: mguests listing chrome, @function denials,
boolexp lock errors, login/page-lock notes, dump progress, @cron usage,
attrcache chrome, @dbclean error, funceval rummaging/step size (~20
sites). Leave blank-line T("") alone (#1443) and tprintf formats as T().
Half-mark pass clean. Regenerate pot/xx without fuzzy entries.
2026-07-27 12:40:51 +00:00
Stephen Dennis
7e3da01e3b fix: validate user-attribute number before anum_table indexing — OOB write / OOM on malformed DB (#808)
Loading a corrupt/malicious DB with an out-of-range user-attribute number
corrupted memory or OOMed: the number indexes anum_table via anum_set (a bare
`anum_table[x]=v` macro) and anum_extend (allocates a dense (x+1) table), with
no validation. The read path atr_num validates anum<0||>top; the write path
(vattr_define_LEN -> anum_extend/anum_set) did not (incomplete hardening,
family of #805/#806/#807).

Live-verified via flatfile import (+A record, novel attr name):
- +A-10000000 -> anum_table[-10000000] write -> SIGSEGV.
- +A-5 -> anum_table[-5] write in valid heap -> silent corruption.
- +A999999999 -> anum_extend allocs ~8GB dense table -> OOM kill.

File-derived numbers reach this from the flatfile +A handler (getref) and the
SQLite attr-name load (db.cpp:3626). A huge number also seeds attr_next enormous
via g_max_nam_atr/max_attrnum_loaded -> later runtime OOM.

Fix:
- New A_USER_MAX (0x01000000 = 16M) constant in attrs.h beside A_USER_START.
- vattr_define_LEN rejects number < A_USER_START || > A_USER_MAX (central backstop).
- The flatfile +A handler and the SQLite attr-name callback validate and skip
  the bad record (graceful degradation; flatfile path logs it).

Verified bite-then-not-bite: malformed +A flatfiles SIGSEGV/silent-corrupt/
OOM-kill on the old build, load cleanly (bad record skipped) on the fixed build;
valid DB still imports; smoke 1115/1115.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 00:08:44 -06:00
Stephen Dennis
dfd0eac7da Qualify std::move calls in vattr.cpp to silence -Wunqualified-std-cast-call
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 19:12:47 -06:00
Stephen Dennis
369f92495c Remove ISOUTOFMEMORY macro; add per-site OOM recovery and fix g_dump_child_pid
Eliminate the ISOUTOFMEMORY macro that unconditionally aborted on allocation
failure. Each of the 23 call sites now handles OOM appropriately:
- Fatal sites (buffer pools, db array, anum table): mux_assert or OutOfMemory
- Recoverable sites (queue, mail, commands, guests, vattrs, config, restart,
  forward lists): log the failure and return gracefully

Also fix g_dump_child_pid portability: volatile pid_t -> volatile sig_atomic_t
with explicit casts in ganl_adapter.cpp.

Close integer overflow issue as false alarm (getstring_noalloc uses a bounded
static buffer, so nBuffer+1 cannot wrap).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 19:31:20 -06:00
Stephen Dennis
9f9d7d75c9 Fix three code review findings from ISSUES.md
1. @dbclean: purge SQLite before mutating in-memory state, so a
   failed purge leaves the process and database consistent.

2. host_strtod: use mux_atof() instead of raw libc strtod() to
   match engine numeric parsing semantics (trailing junk handling,
   special float strings, input clamp).

3. JIT FCALL1/FCALL2: on non-IEEE-SNAN systems, skip native FP
   fast path for domain-guarded functions (ASIN, ACOS, LOG, LOG10,
   SQRT, POWER, FMOD, FDIV) so they fall through to ECALL and
   use the interpreter's "Ind" domain checks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 13:36:58 -06:00
Stephen Dennis
ac58b54c32 Revive @dbclean: purge orphaned vattr names and refresh SQLite stats
@dbclean now finds user-defined attribute names (attrnum >= 256) that
no object references, removes them from both SQLite and the in-memory
vattr maps, then runs ANALYZE to refresh query planner statistics.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 05:40:48 -06:00
Stephen Dennis
4ff1398de1 Restructure mux/ directory: component-based layout with proper build root
Move from flat mux/src/ layout to clean component hierarchy:
- mux/ is now the autoconf/automake build root (configure.ac lives here)
- mux/include/ — shared headers used by multiple components
- mux/lib/ — libmux.so (core utilities, no game state)
- mux/src/ — netmux driver only (thin networking shell)
- mux/modules/engine/ — engine.so (game logic)
- mux/modules/{comsys,mail,exp3,sqlproxy,sqlslave}/ — external modules
- mux/ganl/ — GANL networking library
- mux/sqlite/ — SQLite amalgamation (builds libsqlite3.a)
- mux/announce/ — announce tool (was mux/src/tools/)

Build changes:
- SUBDIRS ordering: ganl sqlite lib src modules announce
- libmux.so gets -Wl,-soname,libmux.so; netmux links via -L -lmux
- engine.so links libsqlite3.a and libmux.so with -Wl,--no-undefined
- RPATH uses $ORIGIN for portable .so resolution
- Install hooks use absolute paths for game/bin symlinks

Bug fixes:
- engine.so mux_Register() now passes nullptr to mux_RegisterClassObjects
  (matches all other modules; libmux already has the factory via dlsym)
- DbConvert() now calls pcache_init() before db_write, fixing a latent
  crash (free(): invalid pointer) when exporting from SQLite databases

411/411 smoke tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 20:38:37 -06:00
Renamed from mux/src/vattr.cpp (Browse further)