Skip to content

scp_recv2 - cannot download file with a name longer than 246 chars #1738

Closed

Description

@psiquo

Describe the bug
When testing scp file download via libssh2_scp_recv2 if the filename in the destination is longer than 246 chars the transfer fails with Error: -28 - Unterminated response from SCP server.

To Reproduce
Compile the scp.c example and run:
examples/.libs/scp <destination> <user> <password> <filename longer than 246 chars>

Expected behavior
The example should print on stdout the contents of the requested file.

Version (please complete the following information):

  • OS and version: Windows 11 - Tested inside Ubuntu 24.04.3 WSL
  • libssh2 version: Tested on both 1.11.1 and master
  • crypto backend and version: Openssl

Additional context
Checking the source code the error is created by this code (lines 664-671 inside src/scp.c).

                      if(session->scpRecv_response_len ==
                          LIBSSH2_SCP_RESPONSE_BUFLEN) {
                          /* You had your chance */
                          _libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
                                         "[2] Unterminated response "
                                         "from SCP server");

Activity

  1. LarsNordin-LNdata commented on Nov 26, 2025

    @LarsNordin-LNdata
    Contributor

    When testing using openssh scp and sftp the xfs-filesystem limits the filename to 255 characters. Maybe libssh2 is missing 9 characters.

    Error in OpenSSH scp when trying to copy to a file with a length > 255 is "Filename to long"

    Error in OpeSSH sftp when trying to copy to a file with a length > 255 is "Bad message"

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions