Skip to content

RANDOM_PADDING in transport.c gets accidentally(?) triggered by Windows wincrypt.h #921

Closed

Description

@zocterminal

I am filing this in relation to tracker issue 793 -- #793

That issue (in my case) deals with a remote server that does not handle the ssh-userauth packet correctly if random padding is enabled. That is probably a bug of that server.

However, as far as I can tell, is that RANDOM_PADDING isn't set in the libssh2 itself (not in my source at least). But in a windows build, in my case instead the source picked up the definition from a windows header (WinCrypt.h) where there is a macro of the same name.

So, although it's not quite a bug, I'd recommend to change the name of that ifdef to something like LIBSSH2_RANDOM_PADDING in transport.c because it's my impression (also from the fixme comment there) that it was not intended to be on.

Activity

  1. vszakats commented on Apr 2, 2023

    @vszakats
    Member

    @Markus-Schmidt Do you know what toolchain/env/config was used for building libssh2 where this Windows macro spilled into transfer.c?

  2. zocterminal commented on Apr 2, 2023

    @zocterminal
    Author

    We're using our own Visual Studio 2010 project with toolset 140 for the build.

    I believe it was imported/made from a visual studio project that came with LIBSSH2 in the old days initially. Like I think around version 1.4 it came with a VisualStudio .dsp project file and we took that project, imported into into ours and are now carrying the VS2010 project file forward ever since by just adding the files that are added to LIBSSH2.

    I know this sounds a bit vague and smells of a home made problem, but a quick test with just an winsock2.h include in an empty source indicates, that the RANDOM_PADDING comes with <winsock2.h>. The following source errors out on complilation in VS2010:

    #include <winsock2.h>
    #ifdef RANDOM_PADDING
    #error RANDOM_PADDING set
    #endif
    
  3. vszakats commented on Apr 2, 2023

    @vszakats
    Member

    @Markus-Schmidt: Thanks for the info! Could not reproduce this in #922 (with VS 2008, 2010, 2013 added). But the small example did reproduce. It happens when WIN32_LEAN_AND_MEAN is not set. I agree it's best to rename this to avoid potential mixups.

  4. added a commit that references this issue on Apr 2, 2023
    d3b3638
  5. zocterminal commented on Apr 2, 2023

    @zocterminal
    Author

    Excellent. Glad to have been of help.

  6. added a commit that references this issue on Mar 28, 2024
    d1b36ef
  7. added a commit that references this issue on Jul 14, 2024
    2006007
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