Skip to content

support full-length UTF-8 path components - #313

Merged
rdmark merged 1 commit into
mainfrom
afp3-filenames
Aug 9, 2026
Merged

support full-length UTF-8 path components#313
rdmark merged 1 commit into
mainfrom
afp3-filenames

Conversation

@rdmark

@rdmark rdmark commented Aug 7, 2026

Copy link
Copy Markdown
Member

Replace the fixed-size AFP URL path and IPC filepath buffers with owned, dynamically allocated storage. Encode IPC paths as length-tagged variable-size payloads, and validate both request and response bounds so valid long paths are neither truncated nor misparsed.

Add URL lifecycle helpers and update callers to manage dynamic paths safely. Apply AFP 3.x filename limits by Unicode character count (up to 255 per component) while retaining byte-based limits for older protocols and encodings.

Add an IPC hello handshake for the Stateless library. The stateless client and afpsld daemon now verify the protocol magic and major version before processing requests; minor-version differences remain compatible.

Add test coverage for long UTF-8 names and IPC namespaces.

@rdmark
rdmark requested a review from andylemin as a code owner August 7, 2026 19:40
@augmentcode

augmentcode Bot commented Aug 7, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR removes fixed AFP URL-path storage in favor of owned dynamic paths.

Changes:

  • Adds public path validation, allocation, copy, join, and cleanup helpers.
  • Updates URL parsing and command-line operations to retain long UTF-8 paths.
  • Reworks stateless IPC path requests into length-tagged variable payloads.
  • Validates IPC request and directory-response bounds before processing them.
  • Adds a daemon/client hello handshake with protocol magic and major-version checks.
  • Prevents URL path pointers from being serialized through stateless and FUSE IPC.
  • Expands filename storage and applies AFP 3.x limits by Unicode character count.
  • Retains byte-oriented restrictions for older AFP encodings and wire formats.
  • Updates command discovery, local-path handling, and lifecycle cleanup for owned strings.
  • Adds coverage for long UTF-8 names, URL paths, discovery allocation, and IPC namespaces.
Technical note: IPC minor versions remain compatible; path-bearing calls now transmit explicit lengths rather than fixed arrays.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread lib/afp_url.c Outdated
Comment thread include/netatalk-client/types.h Outdated
@rdmark
rdmark marked this pull request as draft August 7, 2026 20:01
@rdmark
rdmark marked this pull request as ready for review August 8, 2026 07:43
@rdmark

rdmark commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

augment review

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread cmdline/cmdline_afp.c Outdated

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread cmdline/cmdline_afp.c Outdated
@andylemin

Copy link
Copy Markdown
Contributor

I may be confused, and I may be thinking about ZFS instead of Netatalk, but somewhere n the back of my head I'm thinking that it's not 255 but 511 for some reason.

Also it's not clear exactly which IPC interface this is referring too? Do you mean between FUSE and afpc?

@rdmark

rdmark commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

@andylemin the 255 character limit for file paths originates from AFP, e.g.

https://afp.fyi/docs/programming_guide/concepts/#designating-a-path-to-a-cnode

please let me know if I'm overlooking a crucial fact here and the semantics must be adjusted!

the IPC in question is that between the controller daemons and the client libraries, e.g. afpsld to a client that implements libafpsl. but on second thought I might remove this version check after all -- since we're a pre-release project without an install base it feels like over engineering, even if it will be important to introduce eventually

@andylemin

Copy link
Copy Markdown
Contributor

@rdmark found it; openzfs/zfs#13043

It should be 512 bytes to support 255 Unicode-16 characters plus null terminator.

Notice this is the case for macOS too. So might need to do some digging into this if the spec says 255 characters and we are only providing 256 bytes, while still supporting Unicode-16?

Ok, I understand now, so the IPC is just between the userland and the daemon 👍

Which makes sense as we use FUSE library so there is no IPC in the data path (good).

I don't see anything wrong with the idea of adding robust handling of long paths provided at the userland CLI interfaces.
These are the interfaces which users may build scripts around, so it makes sense.

I guess I'm still waiting to see real world use cases built around the CLI tools. Naively, personally I only expect to use them to setup a mount, and that's probably it.

I'm looking forward to being surprised. CLI Finder search would be useful.

Replace the fixed-size AFP URL path and IPC filepath buffers with owned, dynamically allocated storage. Encode IPC paths as length-tagged variable-size payloads, and validate both request and response bounds so valid long paths are neither truncated nor misparsed.

Add URL lifecycle helpers and update callers to manage dynamic paths safely. Apply AFP 3.x filename limits by Unicode character count (up to 255 per component) while retaining byte-based limits for older protocols and encodings.

Add an IPC hello handshake for the Stateless library. A stateless client and afpsld daemon now verify the protocol magic and major version before processing requests; minor-version differences remain compatible.

Add test coverage for long UTF-8 names and IPC namespaces.
@rdmark

rdmark commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

@andylemin note that we have a 255 character limit on (AFP) paths, but a 65,535 byte buffer for the (joint) paths

before this PR we used a static "scratch buffer" of 768 bytes for every AFP path, used in hundreds of places, and replacing this with the dynamic buffer is what made this refactor this huge.

also note that since this refactor touches the core of the libafpclient library, so the FUSE client benefits from the improved reliability as well -- and so do clients that implement the AFP Stateless library, such as kio-afp

regarding the usefulness of CLI tools: I have found real world use for the batch copy mode of afpcmd, analogous to how scp works

@sonarqubecloud

sonarqubecloud Bot commented Aug 8, 2026

Copy link
Copy Markdown

@andylemin

Copy link
Copy Markdown
Contributor

Great. Thanks for confirming. LGTM

@rdmark
rdmark merged commit cca67f0 into main Aug 9, 2026
23 checks passed
@rdmark
rdmark deleted the afp3-filenames branch August 9, 2026 14:10
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.

2 participants