You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2025/10/15 12:32:49 UTC

(mynewt-core) 01/02: kernel/os_mbuf: Handle buffer copy across mbuf pools

This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit cf1625d3b0d80043298a4add7974ef3d483e6e65
Author: Szymon Czapracki <sz...@codecoup.pl>
AuthorDate: Thu Oct 9 16:10:54 2025 +0200

    kernel/os_mbuf: Handle buffer copy across mbuf pools
    
    Funciton os_mbuf_dup() can overflow on mixed-pool mbuf chains.
    It assumes all mbufs match the first pool’s size and memcpy()s
    larger segments past the destination.
    Make duplication pool-aware.
---
 kernel/os/src/os_mbuf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/os/src/os_mbuf.c b/kernel/os/src/os_mbuf.c
index d5ed8353d..2c193c4f3 100644
--- a/kernel/os/src/os_mbuf.c
+++ b/kernel/os/src/os_mbuf.c
@@ -377,6 +377,9 @@ os_mbuf_dup(struct os_mbuf *om)
     copy = NULL;
 
     for (; om != NULL; om = SLIST_NEXT(om, om_next)) {
+
+        omp = om->om_omp;
+
         if (head) {
             SLIST_NEXT(copy, om_next) = os_mbuf_get(omp,
                     OS_MBUF_LEADINGSPACE(om));