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

Bug in plocate plugin #696

Closed
jadevries opened this issue May 1, 2024 · 3 comments · Fixed by #706
Closed

Bug in plocate plugin #696

jadevries opened this issue May 1, 2024 · 3 comments · Fixed by #706
Assignees
Labels
bug Something isn't working

Comments

@jadevries
Copy link

Using the plocate file parser class outside of the Dissect context I noticed a bug: (almost) every 32nd path gets appended to the previous path.
While testing with target-query I also could reproduce this behaviour on Debian, Ubuntu and Fedora.

I tested and reproduced this on:
Fedora 39: python 3.12.0 (plocate 1.1.17)
Fedora 40: python 3.12.2 & python 3.9.19 (plocate 1.1.22)
Ubuntu 11.04: python 3.10.12 (plocate 1.1.15)
Debian 11: python 3.9.2 (plocate 1.1.8-2)

plugin function used: https://github.com/fox-it/dissect.target/blob/b1bcb0d89d3b24a9ad7e8150d63ddd6dd30a82a2/dissect/target/plugins/os/unix/locate/plocate.py#L138C21-L138C26

@Horofic Horofic added the bug Something isn't working label May 1, 2024
@Horofic
Copy link
Contributor

Horofic commented May 1, 2024

@JSCU-CNI Have you noticed any similar behaviour on your side? This behaviour does not seem to occur in the related test-cases.

@JSCU-CNI
Copy link
Contributor

Thank you for the fix @Horofic. This seems like an oversight from our end. It is not clear to us as to why the end of a zstd frame does not contain a final null byte. Could that be a bug in plocate's zstd implementation? Reading in chunks and splitting on null bytes seems like a reasonable fix to us for now.

@Schamper
Copy link
Member

Schamper commented May 21, 2024

I have not looked at any plocate code, but I can imagine it's a small optimisation if the decompressed data fits entirely within one frame, otherwise you'd have to move the final path to the next frame just to fit the null byte. Especially if you then decompress into a char[FRAME_SIZE + 1] it shouldn't give you any trouble in C.

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 a pull request may close this issue.

4 participants