lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] [lwip] Bug in pbuf_dechain()


From: Lieverse, Paul
Subject: [lwip-users] [lwip] Bug in pbuf_dechain()
Date: Wed, 08 Jan 2003 22:39:33 -0000

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

--------------InterScan_NT_MIME_Boundary
Content-Type: multipart/alternative;
        boundary="----_=_NextPart_001_01C1C11D.86DBF920"

------_=_NextPart_001_01C1C11D.86DBF920
Content-Type: text/plain

Hi,

I detected an error in pbuf_dechain. This function is currently not used, 
but if it's there, it should be correct.

The problem is that the tot_len field of the tail is not adjusted. 
Walking through a simple example already shows this.
For example:
    pbuf_chain(a, b); 
    pbuf_chain(a, c); 
    d = pbuf_dechain(a); 
The tot_len of d (pointing to b) is now incorrect).

The new code: (the if statement plus body is added)

/* pbuf_dechain():
 *
 * Adjusts the ->tot_len field of the pbuf and of the tail (if any) of the
pbuf
 * chain and returns the tail.
 */
/*--------------------------------------------------------------------------
---------*/
struct pbuf *
pbuf_dechain(struct pbuf *p)
{
  struct pbuf *q;
  
  q = p->next;
  if (q != NULL) {
    q->tot_len = p->tot_len - p->len;
  }
  p->tot_len = p->len;
  p->next = NULL;
  return q;
}
/*--------------------------------------------------------------------------
---------*/

Paul

------_=_NextPart_001_01C1C11D.86DBF920
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3DUS-ASCII">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>Bug in pbuf_dechain()</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2 FACE=3D"Arial">Hi,</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">I detected an error in pbuf_dechain. =
This function is currently not used, </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">but if it's there, it should be =
correct.</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">The problem is that the tot_len field =
of the tail is not adjusted. </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Walking through a simple example =
already shows this.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">For example:</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; pbuf_chain(a, b); =
</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; pbuf_chain(a, c); =
</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp;&nbsp;&nbsp; d =3D =
pbuf_dechain(a); </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">The tot_len of d (pointing to b) is =
now incorrect).</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">The new code: (the if statement plus =
body is added)</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Courier New">/* pbuf_dechain():</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp;*</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp;* Adjusts the =
-&gt;tot_len field of the pbuf</FONT> <FONT SIZE=3D2 FACE=3D"Courier =
New">and of the tail (if any) of the pbuf</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp;* chain and returns the =
tail.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp;*/</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier =
New">/*-----------------------------------------------------------------=
------------------*/</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">struct pbuf *</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">pbuf_dechain(struct pbuf =
*p)</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">{</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp; struct pbuf *q;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp; </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp; q =3D p-&gt;next;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp; if (q !=3D NULL) =
{</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp;&nbsp;&nbsp; =
q-&gt;tot_len =3D p-&gt;tot_len - p-&gt;len;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp; }</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp; p-&gt;tot_len =3D =
p-&gt;len;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp; p-&gt;next =3D =
NULL;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">&nbsp; return q;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier New">}</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Courier =
New">/*-----------------------------------------------------------------=
------------------*/</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Courier New">Paul</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C1C11D.86DBF920--

--------------InterScan_NT_MIME_Boundary--

[This message was sent through the lwip discussion list.]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]