codeprentice-org / codeprentice-org/fanotify

Missing DFidName handling, seen with REPORT_NAME

Open
#2 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
14
Forks
1
PR merge metrics
No merged PRs in 30d

Description

If you specify `fanotify::init::Flags::REPORT_NAME`, the read results (can?) have a second header that contains the path segment that changed. This triggers a `TooShort` error (with a misleading message, since there's *extra* data), due to a `if found != expected` test.

https://github.com/codeprentice-org/fanotify/blob/07703f369ec8d480509d087da436a165c8308794/src/event/iterator.rs#L156-L162

If I change that to `if found < expected`, the code works again, but ignores the extra data. Printing it out reveals the first byte is 2, hence `fanotify_event_info_fid.hdr.info_type == 2`, `FAN_EVENT_INFO_TYPE_DFID_NAME`. And it seems this library can request names, but cannot parse them.

It seems `EventIterator` was written to assume there's only one `fanotify_event_info_fid`, but as far as I understand that's not guaranteed. I would suggest the code be changed to treat it as a sequence, and silently ignore unrecognized `info_type` values. That change didn't up being quite trivial enough for me to program it quickly..

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.