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

drivers/dht: fix null deref with saul #20927

Merged
merged 2 commits into from
Oct 21, 2024
Merged

Conversation

Firobe
Copy link
Contributor

@Firobe Firobe commented Oct 20, 2024

Contribution description

The SAUL interface exposes two sensors for humidity and temperature, while the internal dht driver exposes a single dht_read function with two pointers to store humidity and temperature results. The SAUL wrappers pass NULL for the value they're not interested in, but dht_read does not check for that and tries to store both values all the time, causing a segfault.

Testing procedure

The initial bug and its fix have been observed with a DHT11 on a Wemos D1 Mini with the saul shell command.

Issues/PRs references

N/A

@github-actions github-actions bot added the Area: drivers Area: Device drivers label Oct 20, 2024
Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

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

Thanks for finding and fixing, and welcome to the project 🎉

Would you mind updating the function documentation in drivers/include/dht.h to mention the option of passing NULL if not interested, and adding a call doing that to test/drivers/dht/main.c?

@mguetschow mguetschow added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Oct 21, 2024
@riot-ci
Copy link

riot-ci commented Oct 21, 2024

Murdock results

✔️ PASSED

7c68f00 drivers/dht: test and doc

Success Failures Total Runtime
10208 0 10212 17m:09s

Artifacts

@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Oct 21, 2024
@Firobe
Copy link
Contributor Author

Firobe commented Oct 21, 2024

Would you mind updating the function documentation in drivers/include/dht.h to mention the option of passing NULL if not interested, and adding a call doing that to test/drivers/dht/main.c?

Sure! This is done in 7c68f00

Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

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

Perfect, looks good then! Thanks again!

@mguetschow mguetschow added this pull request to the merge queue Oct 21, 2024
Merged via the queue into RIOT-OS:master with commit e5c185b Oct 21, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants