AW: [En-Nut-Discussion] Bug Report

Oliver Schulz Oliver.Schulz at bong.de
Fri Jan 16 08:52:53 CET 2004


Hi Mike,

thanks for finding this bug. 
I think the first intention of not reallocating smaller buffer sizes is not to waste time for over and over releasing and reserving heap memory again.

But of course, if just a smaller buffer size is needed, the nb_XX.sz must be adjusted to the smaller buffer. 
For every buffer type I will add an else part to set the correct nb_XX.sz value.

It's right now in CVS.

Cheers,
Oliver.


-----Ursprüngliche Nachricht-----
Von: Mike Cornelius [mailto:mikec at call-direct.com.au]
Gesendet: Freitag, 16. Januar 2004 06:56
An: en-Nut-Discussion at Egnite. De
Betreff: [En-Nut-Discussion] Bug Report


Hi All,

I have found a bug in NutNetBufAlloc() netbuf.c

In a number of places there are lines like :-

if (nb->nb_XX.sz < size)

If the condition is true (ie the buffer is too small) the old memory block is returned to the heap and a new one assigned nb->nb_XX.sz is updated to reflect the new size and all is OK.

However if the new requested size is smaller than the existing size then nothing happens.
This is a problem because nb->nb_XX.sz does not get updated to reflect the new smaller size and sometime later on when the network dirver goes to send this packet it sends too many bytes.

I've changed the code to if (nb->nb_XX.sz !< size)...

Which works for me but there may be a better way...


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mike Cornelius                      Internet: mikec at call-direct.com.au
Call Direct Cellular Solutions      Phone:    +61 2 9209-4259
Suite 145                           FAX:      +61 2 9209-4196
National Innovation Centre     URL:      http://www.call-direct.com.au
Australian Technology Park
Eveleigh NSW 1430
Australia                  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



More information about the En-Nut-Discussion mailing list