Skip to content

fix: validate numeric and size inputs in the crash handler, power helper and IME popup - #51

Open
perlowja wants to merge 3 commits into
singularityos-lab:mainfrom
ncz-os:fix/harden-helper-inputs
Open

perlowja wants to merge 3 commits into
singularityos-lab:mainfrom
ncz-os:fix/harden-helper-inputs

Conversation

@perlowja

Copy link
Copy Markdown
Contributor

Range and size checks on inputs that previously went unchecked in three places:

  • crash-handler: reject a negative timestamp and uid/gid values that do not fit uid_t/gid_t, cap max_core_mb so the megabyte-to-byte conversion cannot overflow, and stop growing the entry list when the doubled capacity would overflow.
  • power-helper: fail when a sysfs path does not fit its buffer, and reject conversion errors when parsing the charge limit and the charge start threshold.
  • wayland/ime: require a positive stride of at least width * 4 and a width and height whose buffer size fits an int32_t before the popup buffer is created.

Checked with gcc -Wall -Wextra -fsyntax-only on the three files (ime.c with the generated Wayland protocol headers and the gtk4 cflags): no warnings. A full meson build needs valac and was not run.

Generative AI assistance

AI assistance: disclosed

Assisted-by: codex:gpt-6-luna
AI-Scope: Generated the range checks on the numeric arguments and the allocation growth guard from a list of static-analysis sites; reviewed by a human before submission.
Assisted-by: codex:gpt-6-luna
AI-Scope: Generated the path-length and strtol error checks from a list of static-analysis sites; reviewed by a human before submission.
Assisted-by: codex:gpt-6-luna
AI-Scope: Generated the stride and size bounds check from a list of static-analysis sites; reviewed by a human before submission.
@mirkobrombin

Copy link
Copy Markdown
Member

Thanks for going through these. The crash handler and IME checks look fine to me.

One change in power-helper alters behaviour and I would like it adjusted before merging. In charge_limit, when charge_control_start_threshold exists but does not parse as a number, the helper now returns 2 and never writes the charge limit. Before, strtol gave 0 there and the limit was still applied. On a driver that exposes an odd value in that file this turns a working setting into a failure.

The start threshold is only read to decide whether it has to be lowered first, so an unreadable value should skip that adjustment and carry on to set the limit, not abort.

Also, since the description says only -fsyntax-only was run: please do a full build, and if you have a laptop that exposes charge_control_end_threshold, a quick run of the helper setting the limit would be good to have.

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