Re: recv() sends extra garbage bytes
- From: James Antill <james-netnews@xxxxxxx>
- Date: Thu, 29 Mar 2007 11:45:48 -0500
On Thu, 29 Mar 2007 00:07:35 -0700, David Schwartz wrote:
On Mar 28, 6:51 pm, chsal...@xxxxxxxxx wrote:
Thanks for the example code. Should the send() side do a similar loop?
Have a look at the code I posted in my Mar 27 reply. It's simpler, I
think, and saves the extra calls to 'recv'.
I think you mean it's closer in style to the more efficient
implementations, and so is familiar for people well versed in the art
(like yourself). However it contains much more pointer arithmetic and you
have to think about multiple parts of the problem at once, which can be a
significant problem for people not well versed in the art.
I agree it's worth looking at something like that to see where you could
go to improve performance ... but that specific design has very bad worst
case behaviour when you get a lot of data at once (the memmove dominates).
See: http://www.and.org/texts/network_io ... and I'll say again much
like if you want to use a decent RDBMS, understanding how something works
is good but just reusing known working and efficient code is almost
certainly the best thing to do.
Your code was also buggy as hell, which kind of proves my point. The
ones I spotted:
1. packet_len uses <= instead of <<=
2. One side sends two "msgs" and then waits for an answer it deadlocks.
3. memmove uses an offset of buf_ptr instead of packet_len.
4. handling of corrupted data via. packet_len being too big, is not good
(negative values might even be exploitable).
--
James Antill -- james@xxxxxxx
http://www.and.org/and-httpd/ -- $2,000 security guarantee
http://www.and.org/vstr/
.
- Follow-Ups:
- Re: recv() sends extra garbage bytes
- From: David Schwartz
- Re: recv() sends extra garbage bytes
- References:
- recv() sends extra garbage bytes
- From: chsalvia
- Re: recv() sends extra garbage bytes
- From: Frank Cusack
- Re: recv() sends extra garbage bytes
- From: chsalvia
- Re: recv() sends extra garbage bytes
- From: David Schwartz
- Re: recv() sends extra garbage bytes
- From: chsalvia
- Re: recv() sends extra garbage bytes
- From: James Antill
- Re: recv() sends extra garbage bytes
- From: chsalvia
- Re: recv() sends extra garbage bytes
- From: David Schwartz
- recv() sends extra garbage bytes
- Prev by Date: Re: CPU utilization on uLinux
- Next by Date: A quesiton about grep....
- Previous by thread: Re: recv() sends extra garbage bytes
- Next by thread: Re: recv() sends extra garbage bytes
- Index(es):