ssh2.cr icon indicating copy to clipboard operation
ssh2.cr copied to clipboard

Nil Trace error in SSH2::SFTP::File

Open vonKingsley opened this issue 7 years ago • 1 comments

I came across an error doing the following. I updated for Crystal 24 based on the pull request.

Came across this bug using the following require "ssh2"; HTTP::Client.get "http://website.com" Error:

in /usr/local/Cellar/crystal-lang/0.24.1_1/src/http/client.cr:491: instantiating 'IO+#rewind()'

    request.body.try &.rewind

instantiating 'IO+#rewind(Tuple(), NamedTuple())'
in lib/ssh2/src/sftp/file.cr:20: instantiating 'seek(Int32)'

      seek(0)
      ^~~~

in lib/ssh2/src/sftp/file.cr:16: instantiating 'check_error(Nil)'

      check_error(ret)
      ^~~~~~~~~~~

in lib/ssh2/src/sftp/base.cr:25: instantiating 'SSH2::SessionError:Class#check_error(SSH2::Session, Nil)'

    SessionError.check_error(@session, code)
                 ^~~~~~~~~~~

in lib/ssh2/src/ssh2.cr:15: undefined method '>=' for Nil

      if code >= LibSSH2::ERROR_NONE || code == LibSSH2::ERROR_EAGAIN

This traces here I found that libssh2_sftp_seek64 returns Void.

I did a quick fix and just removed the return and check_error method from seek(). I can send up a pull request, but wanted to check with you to see if you think there is a better solution for seek. I don't see anything in the header to indicate a success or failure for seek.

vonKingsley avatar Feb 08 '18 23:02 vonKingsley

same issue with OpenSSH_7.7p1, OpenSSL 1.1.0h-fips 27 Mar 2018

waghanza avatar Jun 27 '18 18:06 waghanza