You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by imoldovan-intacct <gi...@git.apache.org> on 2018/02/15 14:40:16 UTC

[GitHub] httpcomponents-core pull request #59: Avoid endless loop

GitHub user imoldovan-intacct opened a pull request:

    https://github.com/apache/httpcomponents-core/pull/59

    Avoid endless loop

    Of course, I did not think this through...
    This pull request is related to https://github.com/apache/httpcomponents-core/pull/58 .
    
    We might get into an endless loop for sizes which are in (Integer.MAX_VALUE - headRoom, Integer.MAX_VALUE] .

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/imoldovan-intacct/httpcomponents-core master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/httpcomponents-core/pull/59.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #59
    
----
commit 0f16a5b320d46831231ae4e52a77a3e479b9db1d
Author: imoldovan-intacct <im...@...>
Date:   2018-02-12T15:02:06Z

    ExpandableBuffer breaks on large response
    
    Ticket: https://issues.apache.org/jira/browse/HTTPCORE-513

commit 021bb0ee2ed5f3252e3bb0ce153e52369cefaead
Author: imoldovan-intacct <im...@...>
Date:   2018-02-13T13:51:08Z

    ExpandableBuffer breaks on large response
    
    Ticket: https://issues.apache.org/jira/browse/HTTPCORE-513
    This closes #58

commit 5f330017eb22d0d75caf0b9585efd63a1d003b49
Author: imoldovan-intacct <im...@...>
Date:   2018-02-15T14:00:14Z

    ExpandableBuffer breaks on large response
    
    Ticket: https://issues.apache.org/jira/browse/HTTPCORE-513
    
    Missed an endless loop when the size is in (Integer.MAX_VALUE - headRoom, Integer.MAX_VALUE] .

commit db22f6c1eb371f52526af19f14687ab7912bddb7
Author: imoldovan-intacct <im...@...>
Date:   2018-02-15T14:19:03Z

    Undo
    
    undo for merge

commit e619cd8d566e586de6d8fe723bd4c091b034dda5
Author: imoldovan-intacct <im...@...>
Date:   2018-02-15T14:33:33Z

    ExpandableBuffer breaks on large response
    
    Ticket: https://issues.apache.org/jira/browse/HTTPCORE-513
    
    Endless loop for sizes in (Integer.MAX_VALUE - headRoom, Integer.MAX_VALUE] .

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] httpcomponents-core issue #59: Avoid endless loop

Posted by ok2c <gi...@git.apache.org>.
Github user ok2c commented on the issue:

    https://github.com/apache/httpcomponents-core/pull/59
  
    @imoldovan-intacct I would rather use `BufferOverflowException` instead of `MessageConstraintException`


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] httpcomponents-core pull request #59: Avoid endless loop

Posted by imoldovan-intacct <gi...@git.apache.org>.
Github user imoldovan-intacct commented on a diff in the pull request:

    https://github.com/apache/httpcomponents-core/pull/59#discussion_r168498931
  
    --- Diff: httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ExpandableBuffer.java ---
    @@ -123,6 +123,10 @@ protected void expand() {
                 // WARNING: This code assumes you are providing enough heap room with -Xmx.
                 // source of inspiration: https://bugs.openjdk.java.net/browse/JDK-8059914
                 newcapacity = Integer.MAX_VALUE - headRoom;
    +            if (newcapacity == this.buffer.capacity()) {
    --- End diff --
    
    There is no way for this.buffer.capacity() to exceed Integer.MAX_VALUE - headRoom.
    When we get to the point that they are equal => we already have touched maximum buffer capacity allowed once (MAX_VALUE - 8 in our case) and we are going inside an endless loop.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] httpcomponents-core pull request #59: Avoid endless loop

Posted by imoldovan-intacct <gi...@git.apache.org>.
Github user imoldovan-intacct commented on a diff in the pull request:

    https://github.com/apache/httpcomponents-core/pull/59#discussion_r168498667
  
    --- Diff: httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ExpandableBuffer.java ---
    @@ -123,6 +123,10 @@ protected void expand() {
                 // WARNING: This code assumes you are providing enough heap room with -Xmx.
                 // source of inspiration: https://bugs.openjdk.java.net/browse/JDK-8059914
                 newcapacity = Integer.MAX_VALUE - headRoom;
    +            if (newcapacity == this.buffer.capacity()) {
    --- End diff --
    
    I did that.
    I also did a beginner mistake :) . I'll try not to commit with too much coffee on board anymore.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] httpcomponents-core pull request #59: Avoid endless loop

Posted by ok2c <gi...@git.apache.org>.
Github user ok2c commented on a diff in the pull request:

    https://github.com/apache/httpcomponents-core/pull/59#discussion_r168499443
  
    --- Diff: httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ExpandableBuffer.java ---
    @@ -123,6 +123,10 @@ protected void expand() {
                 // WARNING: This code assumes you are providing enough heap room with -Xmx.
                 // source of inspiration: https://bugs.openjdk.java.net/browse/JDK-8059914
                 newcapacity = Integer.MAX_VALUE - headRoom;
    +            if (newcapacity == this.buffer.capacity()) {
    --- End diff --
    
    bq. There is no way for this.buffer.capacity() to exceed Integer.MAX_VALUE - headRoom
    @imoldovan-intacct  Probably, but still looks a little safer


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] httpcomponents-core pull request #59: Avoid endless loop

Posted by ok2c <gi...@git.apache.org>.
Github user ok2c commented on a diff in the pull request:

    https://github.com/apache/httpcomponents-core/pull/59#discussion_r168495541
  
    --- Diff: httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ExpandableBuffer.java ---
    @@ -123,6 +123,10 @@ protected void expand() {
                 // WARNING: This code assumes you are providing enough heap room with -Xmx.
                 // source of inspiration: https://bugs.openjdk.java.net/browse/JDK-8059914
                 newcapacity = Integer.MAX_VALUE - headRoom;
    +            if (newcapacity == this.buffer.capacity()) {
    --- End diff --
    
    @imoldovan-intacct  why not `newcapacity >= this.buffer.capacity()` ?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] httpcomponents-core issue #59: Avoid endless loop

Posted by imoldovan-intacct <gi...@git.apache.org>.
Github user imoldovan-intacct commented on the issue:

    https://github.com/apache/httpcomponents-core/pull/59
  
    Thanks for the suggestions. It's all good now.
    I do have some improvements in mind for the buffer allocation, but I preferred to stick to the burning issue for now.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] httpcomponents-core pull request #59: Avoid endless loop

Posted by ok2c <gi...@git.apache.org>.
Github user ok2c commented on a diff in the pull request:

    https://github.com/apache/httpcomponents-core/pull/59#discussion_r168497884
  
    --- Diff: httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ExpandableBuffer.java ---
    @@ -123,6 +123,10 @@ protected void expand() {
                 // WARNING: This code assumes you are providing enough heap room with -Xmx.
                 // source of inspiration: https://bugs.openjdk.java.net/browse/JDK-8059914
                 newcapacity = Integer.MAX_VALUE - headRoom;
    +            if (newcapacity == this.buffer.capacity()) {
    --- End diff --
    
    @imoldovan-intacct you might also want to rebase your branch off the upstream master. 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[GitHub] httpcomponents-core pull request #59: Avoid endless loop

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/httpcomponents-core/pull/59


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org