Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Longname causes hard crash if mtime attr isn't set. #146

Open
SamODonnell89 opened this issue Apr 11, 2023 · 0 comments
Open

Longname causes hard crash if mtime attr isn't set. #146

SamODonnell89 opened this issue Apr 11, 2023 · 0 comments

Comments

@SamODonnell89
Copy link

SamODonnell89 commented Apr 11, 2023

Ran into a case where a client's SFTP server had files and folders with no attributes set for mtime, createtime etc. This causes a hard crash TypeError (can't convert nil into an exact number)

Tried to create a PR to resolve this but received a 403 when trying to push.

name.rb

longname << Time.at(attributes.mtime || 0).strftime("%b %e %H:%M ")

test_name.rb

@directory_no_mtime = Net::SFTP::Protocol::V04::Name.new("test", Net::SFTP::Protocol::V04::Attributes.new(:type => 2, :mtime => nil, :owner => "jamis", :group => "users", :size => 1024, :permissions => 0755))
...

def test_longname_should_fallback_to_time_at_0_if_mtime_is_nil
    assert_equal "drwxr-xr-x jamis    users        1024 Jan  1 00:00 test",
      @directory_no_mtime.longname
end
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

No branches or pull requests

1 participant