2007/6/7, David Bertoni <[EMAIL PROTECTED]>:
Jose Luis Zabalza wrote:
> Hello list
>
> int t=recv(fSource, x, maxToRead, 0);
This is most likely a buffer overrun, since x is 1000 bytes, and you've
passed in maxToRead to recv. This should be:
Sorry. I would say
int t=recv(fSource, toFill, maxToRead, 0);
> for(Result=0;Result<t;Result++)
> toFill[Result]=x[Result];
This is also a buffer overrun, since t may be greater than 1000.
Yes, it's posible but not in this case (testing) because never arrive
more 1000 bytes (usually 100)
> there are not problems but if x is a private member of MY_InputStream,
>
> class MY_InputStream : public BinInputStream
> {
> private :
> char x[1000];
>
>
> I get a runtime error.
>
> *** glibc detected *** free(): invalid next size (fast): 0x0805b0d0 ***
When the buffer is on the stack, you overwrite the stack. When the buffer
is a data member, you overwrite the block of memory allocated for the
object. You are most likely destroying crucial data the heap allocator needs.
Yes, I know but in this case (testing) I send 100 bytes and it is
imposible overwrite the block.
Thanks.
--
José Luis Zabalza
jlz.3008 a t gmail.com
Linux Counter 172551