Skip to content

dash-spv: the user agent is no longer normalized or capped at 256 bytes #1242

Closed

Description

@xdustinface

All paths are under dash-spv/src/ at 8dde9d0c (dev after #902).

build_version sends user_agent exactly as configured (network/peer.rs:538-552). Before #902, handshake.rs wrapped it in / delimiters and truncated it at 256 bytes. Dash Core reads the field with LIMITED_STRING(strSubVer, MAX_SUBVERSION_LENGTH) (net_processing.cpp:4020, limit 256 in net.h:86), which throws on a longer string. Core catches the exception and only logs it (net_processing.cpp:6002-6005), so our version is dropped, Core never sends its own, and the handshake times out. This only affects a custom user agent longer than 256 bytes, the default is short.

Evidence. A throwaway test set a 300-byte agent through ClientConfig::default().with_user_agent(..), built the version message and round-tripped it:

wire user_agent.len() = 300
starts_with '/' = false, ends_with '/' = false
core would throw (len > MAX_SUBVERSION_LENGTH=256): true

client/config.rs:192 and dash-spv-ffi/src/config.rs:186 still promise normalization. ClientConfig::user_agent changed from Option<String> to String in the same change, a public API break that the #902 title did not mark with !. The default also changed from /rust-dash-spv:VER/ to /dash-spv:VER/, while the devnet agent still uses rust-dash-spv.

Fix. Restore the normalization in build_version (add the delimiters, truncate on a char boundary at 256), and align the devnet agent with the new default.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions