Uploaded image for project: 'Maven Wagon'
  1. Maven Wagon
  2. WAGON-485

ScpWagon parses file size to int causing overflow for large files

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.10
    • Fix Version/s: 2.12
    • Component/s: wagon-ssh
    • Labels:
      None

      Description

      ScpWagon class parses a string value to integer (file size) but if you have a large file (3.6 GB for example) the file size is 3865470566 in bytes, the number is larger than the MAX_VALUE of integer.

      ScpWagon.java
      public void fillInputData( InputData inputData )
              throws TransferFailedException, ResourceDoesNotExistException {
      ...
      int filesize = Integer.valueOf( line.substring( 5, index ) ).intValue();
      fireTransferDebug( "Remote file size: " + filesize );
      
      resource.setContentLength( filesize );
      ...
      

      I changed the line to parse using Long because the resource.setContentLength method receive a long value too.

      ScpWagon.java
      long filesize = Long.valueOf( line.substring( 5, index ) );
      

      Please check the pull-request https://github.com/apache/maven-wagon/pull/32

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user Tunaki commented on a diff in the pull request:

          https://github.com/apache/maven-wagon/pull/32#discussion_r95232415

          — Diff: wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java —
          @@ -297,7 +297,7 @@ public void fillInputData( InputData inputData )
          throw new IOException( "Invalid transfer header: " + line );
          }

          • int filesize = Integer.valueOf( line.substring( 5, index ) ).intValue();
            + long filesize = Long.valueOf( line.substring( 5, index ) );
              • End diff –

          Small note, `Long.parseLong` is better here as it wouldn't involve an unboxing conversion.

          Show
          githubbot ASF GitHub Bot added a comment - Github user Tunaki commented on a diff in the pull request: https://github.com/apache/maven-wagon/pull/32#discussion_r95232415 — Diff: wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java — @@ -297,7 +297,7 @@ public void fillInputData( InputData inputData ) throw new IOException( "Invalid transfer header: " + line ); } int filesize = Integer.valueOf( line.substring( 5, index ) ).intValue(); + long filesize = Long.valueOf( line.substring( 5, index ) ); End diff – Small note, `Long.parseLong` is better here as it wouldn't involve an unboxing conversion.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on a diff in the pull request:

          https://github.com/apache/maven-wagon/pull/32#discussion_r95234762

          — Diff: wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java —
          @@ -297,7 +297,7 @@ public void fillInputData( InputData inputData )
          throw new IOException( "Invalid transfer header: " + line );
          }

          • int filesize = Integer.valueOf( line.substring( 5, index ) ).intValue();
            + long filesize = Long.valueOf( line.substring( 5, index ) );
              • End diff –

          Good point. Waiting for this to be integrated and I will ran all tests against the patch.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on a diff in the pull request: https://github.com/apache/maven-wagon/pull/32#discussion_r95234762 — Diff: wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java — @@ -297,7 +297,7 @@ public void fillInputData( InputData inputData ) throw new IOException( "Invalid transfer header: " + line ); } int filesize = Integer.valueOf( line.substring( 5, index ) ).intValue(); + long filesize = Long.valueOf( line.substring( 5, index ) ); End diff – Good point. Waiting for this to be integrated and I will ran all tests against the patch.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user oassuncao commented on the issue:

          https://github.com/apache/maven-wagon/pull/32

          Changed the code to use `Long.parseLong`

          Show
          githubbot ASF GitHub Bot added a comment - Github user oassuncao commented on the issue: https://github.com/apache/maven-wagon/pull/32 Changed the code to use `Long.parseLong`
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user michael-o commented on the issue:

          https://github.com/apache/maven-wagon/pull/32

          Please squash them.

          Show
          githubbot ASF GitHub Bot added a comment - Github user michael-o commented on the issue: https://github.com/apache/maven-wagon/pull/32 Please squash them.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user oassuncao commented on the issue:

          https://github.com/apache/maven-wagon/pull/32

          I squash the commits.

          Thanks

          Show
          githubbot ASF GitHub Bot added a comment - Github user oassuncao commented on the issue: https://github.com/apache/maven-wagon/pull/32 I squash the commits. Thanks
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user stephenc commented on the issue:

          https://github.com/apache/maven-wagon/pull/32

          LGTM

          Show
          githubbot ASF GitHub Bot added a comment - Github user stephenc commented on the issue: https://github.com/apache/maven-wagon/pull/32 LGTM
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/maven-wagon/pull/32

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/maven-wagon/pull/32
          Hide
          michael-o Michael Osipov added a comment -
          Show
          michael-o Michael Osipov added a comment - Fixed with 3512a321ef678209167fa978d5aafe2fdf6bfff7 .
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build maven-wagon #1334 (See https://builds.apache.org/job/maven-wagon/1334/)
          WAGON-485 ScpWagon parses file size to int causing overflow for large (michaelo: http://git-wip-us.apache.org/repos/asf/?p=maven-wagon.git&a=commit&h=3512a321ef678209167fa978d5aafe2fdf6bfff7)

          • (edit) wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-wagon #1334 (See https://builds.apache.org/job/maven-wagon/1334/ ) WAGON-485 ScpWagon parses file size to int causing overflow for large (michaelo: http://git-wip-us.apache.org/repos/asf/?p=maven-wagon.git&a=commit&h=3512a321ef678209167fa978d5aafe2fdf6bfff7 ) (edit) wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java

            People

            • Assignee:
              michael-o Michael Osipov
              Reporter:
              assuncao.s Silvio Assuncao
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development