[ 
https://issues.apache.org/jira/browse/THRIFT-6258?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jens Geyer resolved THRIFT-6258.
--------------------------------
    Fix Version/s: 0.26.0
         Assignee: Jens Geyer
       Resolution: Fixed

> Smalltalk: TTransport>>readAll: loops forever when read: returns no bytes
> -------------------------------------------------------------------------
>
>                 Key: THRIFT-6258
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6258
>             Project: Thrift
>          Issue Type: Bug
>          Components: Smalltalk - Library
>            Reporter: Jens Geyer
>            Assignee: Jens Geyer
>            Priority: Minor
>             Fix For: 0.26.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> {{lib/st/thrift.st:789}}:
> {code}
> readAll: anInteger
>       ^ String streamContents: [:str |
>               [str size < anInteger] whileTrue:
>                       [str nextPutAll: (self read: anInteger - str size)]]
> {code}
> The loop asks {{read:}} for the bytes it still needs and appends the result. 
> A {{read:}} that answers an empty string appends nothing, and asking the same 
> source again cannot change that, so {{whileTrue:}} has no way to end. Nothing 
> in {{thrift.st}} answers an empty string from {{read:}} today, so this is not 
> reachable as the library stands; it is a contract that any new or third-party 
> transport can break silently.
> c_glib had the same shape in {{thrift_transport_real_read_all()}} and it was 
> given an explicit progress check.
> h2. Suggested fix
> Signal a {{TTransportError}} when {{read:}} answers nothing, rather than 
> repeating a call that cannot advance.
> The same loop exists in {{lib/php/lib/Transport/TTransport.php}} and 
> {{lib/perl/lib/Thrift/Transport.pm}}; those are filed separately.
> _Drafted with AI assistance (Claude Opus 5); reviewed and filed by Jens 
> Geyer._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to