Skip to content

Harden Tosu init, poll handling, and local request trust#3

Open
sciboy12 wants to merge 1 commit intorewrite-scaling-config-reworkfrom
codex/consolidate-cleanup-patch-for-abs-c.c-and-tosuhandler.c
Open

Harden Tosu init, poll handling, and local request trust#3
sciboy12 wants to merge 1 commit intorewrite-scaling-config-reworkfrom
codex/consolidate-cleanup-patch-for-abs-c.c-and-tosuhandler.c

Conversation

@sciboy12
Copy link
Copy Markdown
Owner

@sciboy12 sciboy12 commented Apr 7, 2026

Motivation

  • Prevent use of an uninitialized active when Tosu integration is enabled.
  • Make the main input loop handle poll() errors and interrupts explicitly instead of treating any non-positive return as a silent continue.
  • Reduce local trust surface for Tosu HTTP requests and remove an unused dead local in main.

Description

  • Initialize active to false and, when Tosu is enabled, set active = tosu_get_absolute_state() immediately after tosu_init() in abs-c.c to avoid uninitialized reads.
  • Replace the condensed if (poll(&pfd, 1, -1) <= 0) continue; with explicit handling: check poll() return value, continue on EINTR (unless stop is set), call perror("poll") and break on hard errors, continue on timeout (0), preserve fatal pfd.revents checks and require POLLIN before reading.
  • Remove the unused struct input_event ev_buf[64]; declaration from main in abs-c.c.
  • Add #include <errno.h> to support robust poll() errno checks.
  • In tosuhandler.c, change TOSU_URL from http://localhost:24050/json to http://127.0.0.1:24050/json and set CURLOPT_NOPROXY to "*" to prevent environment proxying while preserving existing redirect and protocol settings.
  • Inspected emit_abs_delta and made no change because there was no duplicated unreachable return false; in the current tree.

Testing

  • Ran git diff -- abs-c.c tosuhandler.c to verify the code delta (succeeded).
  • Ran git status --short to confirm staged changes (succeeded).
  • Ran make clean && make to attempt a build; the build failed in this environment due to missing development headers/libraries (ini.h, cjson/cJSON.h) and not due to the applied changes.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant