Skip to content

/proc/acpi/nuc_led output is null character terminated (potential buffer overflow) #15

Description

@ju2wheels

This IMO is a subtle bug which may be an off by one error somewhere in the generated output string buffer index.

In general if you use Bash to capture the output of the /proc/acpi/nuc_led to later process it like this:

nuc_led_output="$(cat /proc/acpi/nuc_led)"

Then you get a warning along the lines of:

Bash: warning: command substitution: ignored null byte in input

This is because you are adding the null byte ('\0') into the middle of the Bash string which internally is also a C string, so it ignores it.

This leads me to believe that the function that is creating the string buffer is either printing one character past the end of the actual buffer and overflowing it (causing the null character to be printed) or its being purposely injected/included in the output string. It would be better for the null byte not to be included in the output.

As a workaround, I have just been translating away the null byte:

nuc_led_output="$(cat /proc/acpi/nuc_led | tr "\0" "\n")"

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions