Jump to content
idontknow

EIntOverflow in OverbyteIcsHttpProt.pas in THttpCli

Recommended Posts

i just had an EIntOverflow in OverbyteIcsHttpProt.pas while receiving an mjpeg-stream from a camera, started some (5?) days ago.

The problem was the line "Inc(FBodyLineCount)" in "procedure THttpCli.GetBodyLineNext":

 

{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{ Data is pointed by FBodyData and FBodyDataLen as length                   }
procedure THttpCli.GetBodyLineNext;
var
//  P    : PChar;
    P    : Integer; // (FP 09/09/06)
    N, K : THttpBigInt;
begin
{$IFNDEF NO_DEBUG_LOG}
    if CheckLogOptions(loProtSpecInfo) then  { V1.91 } { replaces $IFDEF DEBUG_OUTPUT  }
        DebugLog(loProtSpecInfo, 'GetBodyLineNext begin');
{$ENDIF}
    if FBodyLineCount = 0 then begin
        FChunkLength := 0;
        FChunkRcvd   := 0;
        FChunkState  := httpChunkGetSize;
        TriggerDocBegin;
{$IFDEF UseContentCoding}
        FContentCodingHnd.Prepare(FContentEncoding);
        if Assigned(FRcvdStream) then
            FRcvdStreamStartSize := FRcvdStream.Size
        else
            FRcvdStreamStartSize := 0;
{$ENDIF}
    end;
    Inc(FBodyLineCount); // OD EIntOverflow am 07.04.2021 with FBodyLineCount: Suggest changing type to Int64.
{$IFNDEF NO_DEBUG_LOG}
    if CheckLogOptions(loProtSpecInfo) then  { V1.91 } { replaces $IFDEF DEBUG_OUTPUT  }
        DebugLog(loProtSpecInfo, 'GetBodyLineNext FBodyDataLen=' + IntToStr(FBodyDataLen));
{$ENDIF}
    ...


I suppose turn around to 0 with Overflow-Checks off will have some unwanted sideeffects, as initializing FChunkLength and several other variables to zero.

I think, changing the vartype of the member variable "FBodyLineCount" from Integer to Int64 will solve the problem (for my lifetime).

Share this post


Link to post

You reported this rare bug by email, and it was fixed in SVN and the overnight zip last week.  The counter was only used as a simple flag so was changed to boolean. 

 

Angus

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×