In my last commit (adding task statistics to the OS), I fixed a rather major bug in os_mbuf_append().

As you can see below, when copying data into a _new_ MBUF using os_mbuf_append(), the data was previously overwriting the contents of the input mbuf, instead of writing data into the new mbuf, which was being appended.

This caused data to be overwritten whenever you used os_mbuf_append() in a chained scenario.

Sterling


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/902da3c2/libs/os/src/os_mbuf.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_mbuf.c b/libs/os/src/os_mbuf.c
index 9453960..844af80 100644
--- a/libs/os/src/os_mbuf.c
+++ b/libs/os/src/os_mbuf.c
@@ -388,7 +388,7 @@ os_mbuf_append(struct os_mbuf *om, const void *data, uint16_t len)
             space = remainder;
         }

-        memcpy(OS_MBUF_DATA(last, void *) + last->om_len , data, space);
+        memcpy(OS_MBUF_DATA(last, uint8_t *) + last->om_len , data, space);

         last->om_len += space;
         data += space;
@@ -405,7 +405,7 @@ os_mbuf_append(struct os_mbuf *om, const void *data, uint16_t len)
         }

         new->om_len = min(omp->omp_databuf_len, remainder);
-        memcpy(OS_MBUF_DATA(om, void *), data, new->om_len);
+        memcpy(OS_MBUF_DATA(new, void *), data, new->om_len);
         data += new->om_len;
         remainder -= new->om_len;
         SLIST_NEXT(last, om_next) = new;

Reply via email to