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

aliases: strip NULL byte before returning the strings #6

Merged
merged 1 commit into from
Apr 1, 2022

Conversation

ardbiesheuvel
Copy link
Contributor

Resolving aliases doesn't quite work as it should right now, because the
strings contain trailing NULL bytes that don't match the node names. So
ensure that those NULL bytes are stripped.

Resolving aliases doesn't quite work as it should right now, because the
strings contain trailing NULL bytes that don't match the node names. So
ensure that those NULL bytes are stripped.
@repnop
Copy link
Owner

repnop commented Mar 31, 2022

Hi and thanks for the PR! I'm surprised I haven't hit this myself actually! Only nit is that I think I'd prefer .map(|s| s.trim_end_matches('\0')) in the (very unlikely) case that the value is empty for some reason or someone mistakenly appended an extra null, so as to not panic there.

@ardbiesheuvel
Copy link
Contributor Author

Hi and thanks for the PR! I'm surprised I haven't hit this myself actually! Only nit is that I think I'd prefer .map(|s| s.trim_end_matches('\0')) in the (very unlikely) case that the value is empty for some reason or someone mistakenly appended an extra null, so as to not panic there.

Sure, but that concern applies equally to the other occurrences of the &pvalue[..p.value.len() - 1] pattern that occur in the same file.

@repnop
Copy link
Owner

repnop commented Apr 1, 2022

Ah good catch, didn't realize I was doing it in other places as well. I'll merge this then and fix them up in a commit afterwards. Thanks!

@repnop repnop merged commit 22f1282 into repnop:master Apr 1, 2022
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

2 participants