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

mraa: fix mraa_file_contains() and mraa_file_contains_both() #979

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

mraa: fix mraa_file_contains() and mraa_file_contains_both() #979

wants to merge 1 commit into from

Conversation

lbxl2345
Copy link

@lbxl2345 lbxl2345 commented Aug 1, 2019

These two functions may return wrong results if lines in the
file contains embedded '\0' characters.

For example, file "/proc/device-tree/compatible" could have
multiple values in one line (corresponding to the dts), and the
values are separated with '\0'.

In this situation, we need to replace the embedded '\0' and check
the entire line. If we don't do this, only the first value is
checked by strstr(), and the function may return false even if
the file contains certain content.

Signed-off-by: Benxi Liu bxliu@linux.alibaba.com

These two functions may return wrong results if lines in the
file contains embedded '\0' characters.

For example, file "/proc/device-tree/compatible" could have
multiple values in one line (corresponding to the dts), and the
values are separated with '\0'.

In this situation, we need to replace the embedded '\0' and check
the entire line. If we don't do this, only the first value is
checked by strstr(), and the function may return false even if
the file contains certain content.

Signed-off-by: Benxi Liu <bxliu@linux.alibaba.com>
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.

None yet

1 participant