Skip to content

fix: check legal_path before calling compile_object apply#398

Merged
taedlar merged 4 commits into
mainfrom
filepath_ops
May 29, 2026
Merged

fix: check legal_path before calling compile_object apply#398
taedlar merged 4 commits into
mainfrom
filepath_ops

Conversation

@taedlar

@taedlar taedlar commented May 27, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens filesystem sandboxing by validating object source paths with legal_path() before any virtual-object (master::compile_object()) lookup occurs, while also consolidating path handling around the misc/filepath.* helpers and adding unit tests for those helpers.

Changes:

  • Enforce early legal_path() validation and stricter mudlib-root anchoring in load_object() to prevent unsafe paths from reaching compile_object.
  • Refactor path composition/normalization to use filepath_join() / filepath_resolve_with_origin() across startup and file efuns.
  • Add a new GoogleTest suite for filepath helper functions and wire it into CMake.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_filepath/test_filepath.cpp Adds unit tests for path validation, containment checks, joining, stripping, and origin-relative resolution.
tests/test_filepath/CMakeLists.txt Builds and registers the new test_filepath test binary.
CMakeLists.txt Adds tests/test_filepath to the test build when GTest is enabled.
src/stem.cpp Switches mudlib-root path composition to filepath_join() for bounded joining + containment verification.
src/main.c Resolves __LOG_DIR__ relative to config location and joins it with __DEBUG_LOG_FILE__ via filepath helpers.
lib/rc/rc.cpp Resolves mudlib dir relative to the config file using filepath_resolve_with_origin() before filesystem checks.
lib/misc/filepath.h Renames/reshapes the filepath helper APIs (filepath_strip, filepath_join, filepath_resolve_with_origin).
lib/misc/filepath.cpp Implements the updated filepath helper APIs (strip in-place, join full path, resolve relative-to-origin).
src/simulate.h Renames load_object parameter to name_or_path for clarity.
src/simulate.c Canonicalizes object names, checks legal_path() before virtual object lookup, and uses verified mudlib-root joining.
lib/lpc/otable.h Exposes make_otable_name() and keeps strip_name() as a legacy inline wrapper.
lib/lpc/otable.c Implements make_otable_name() (strip leading slashes, collapse repeated “.c”), and updates add_slash() return type.
lib/lpc/compiler.c Renames compile_file() parameter from name to source_file for clarity in tracing/logging.
lib/efuns/file_utils.c Updates rename/cp helpers to use new filepath helpers and preserve basename-append behavior explicitly.

Comment thread src/simulate.c
Comment thread lib/efuns/file_utils.c
@taedlar taedlar merged commit 12c82cb into main May 29, 2026
2 checks passed
@taedlar taedlar deleted the filepath_ops branch May 29, 2026 15:19
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.

2 participants