🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #3269

Re: i need ideas/comments with tclientsocket

#3269
From: Remy Lebeau (TeamB)
Date: Tue, 01 Nov 2005 09:15
40 lines
2769 bytes
"Hans Galema" <notused@notused.nl> wrote in message
news:43672a80$1@newsgroups.borland.com...

> The adjusting of Size is needed.

Adjusting the Size in general is needed, of course.  That is not what I was
arguing against.  The way that you are doing it is not needed.  You don't
need to check whether the (Position + receivelength) will exceed the current
Size.  Partly because that condition will always be true.  Partly because
the Size already does the validation internally so there is no need to
manually duplicate what TMemoryStream is already doing for you
automatically.  And Partly because your use of the '+=' operator is wrong
anyway.  You cannot use the '+=' operator with properties, it doesn't work
correctly.

These lines are unnecessary:

    if ( MemoryStream->Position + receivelength >= MemoryStream->Size )
        MemoryStream->Size += receivelength + 1; // +1 is not needed I think

All that is needed is the following:

    MemoryStream->Size = MemoryStream->Size + receivelength;

If you really want to continue checking the Position beforehand, then you
need to fix your assignment of the Size property, because you are setting it
to the wrong value.  It should be more like like this instead:

    MemoryStream->Size = (MemoryStream->Position + receivelength);

> If ->Memory had not sufficiend Size then above statement, that
> puts bytes directly in the Memory-buffer, would produce a bufferoverflow.

That is not the point I was arguing.  Of course the Size has to be
sufficient before reading into it.  But you are performing unnecessary
operations in regards to it.


Gambit
Technical Details
Message-ID: <43673233$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!mpls-transit-01.news.qwest.net!38.119.97.78.MISMATCH!news-out.superfeed.net!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43662baf$1@newsgroups.borland.com> <43664511@newsgroups.borland.com> <4366672a$1@newsgroups.borland.com> <43668460@newsgroups.borland.com> <4366d220$1@newsgroups.borland.com> <43672a80$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,5c33b8c6a9ca7fdb
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <43662baf$1@newsgroups.borland.com> <43664511@newsgroups.borland.com> <4366672a$1@newsgroups.borland.com> <43668460@newsgroups.borland.com> <4366d220$1@newsgroups.borland.com> <43672a80$1@newsgroups.borland.com>
Subject: Re: i need ideas/comments  with tclientsocket
Date: Tue, 1 Nov 2005 01:15:34 -0800
Lines: 42
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <43673233$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1130836531 68.69.17.41 (1 Nov 2005 01:15:31 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!mpls-transit-01.news.qwest.net!38.119.97.78.MISMATCH!news-out.superfeed.net!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail