Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on invalid curve config #93

Merged
merged 1 commit into from
Feb 19, 2022

Conversation

Smeat
Copy link
Contributor

@Smeat Smeat commented Feb 17, 2022

If one provides an invalid curve configuration with neither linear nor function fan2go crashes with a segmentation fault.

Example config snippets (based on the example config):

curves:
  - id: cpu_curve
    # typo
    linearr:
      sensor: cpu_package
      steps:
        - 40: 0
        - 50: 50
        - 80: 255

or

curves:
  - id: cpu_curve

Crash:

INFO  Using configuration file at: /tmp/fan2go/fan2go.yaml
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x7ae3c2]

No clue why TestValidateCurveSubConfigSensorIdIsMissing doesn't catch this error.
Sorry I am not sure on how to add a test with an actual config file.

@markusressel
Copy link
Owner

Thx!
This is due to the order of the validation, sensors are validated first.
It should be possible to create a test for this scenario, but I guess this is fine for now.

@markusressel markusressel merged commit b3e4a1e into markusressel:master Feb 19, 2022
@markusressel markusressel added the bug Something isn't working label Feb 19, 2022
@Smeat Smeat deleted the fix_config_crash branch February 19, 2022 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants