You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2016/08/11 21:27:28 UTC
[28/50] [abbrv] incubator-mynewt-core git commit: os_mbuf_appendfrom
- Detect source mbuf overrun.
os_mbuf_appendfrom - Detect source mbuf overrun.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/a248989e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a248989e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a248989e
Branch: refs/heads/phyrx_no_mbuf
Commit: a248989e2a86b05a8460719ae9047baf239db2aa
Parents: e5413e6
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Aug 9 12:29:28 2016 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Thu Aug 11 14:26:26 2016 -0700
----------------------------------------------------------------------
libs/os/src/os_mbuf.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a248989e/libs/os/src/os_mbuf.c
----------------------------------------------------------------------
diff --git a/libs/os/src/os_mbuf.c b/libs/os/src/os_mbuf.c
index eda58ef..a2302df 100644
--- a/libs/os/src/os_mbuf.c
+++ b/libs/os/src/os_mbuf.c
@@ -520,6 +520,10 @@ err:
* @param src_off The absolute offset within the source mbuf
* chain to read from.
* @param len The number of bytes to append.
+ *
+ * @return 0 on success;
+ * OS_EINVAL if the specified range extends beyond
+ * the end of the source mbuf chain.
*/
int
os_mbuf_appendfrom(struct os_mbuf *dst, const struct os_mbuf *src,
@@ -531,11 +535,11 @@ os_mbuf_appendfrom(struct os_mbuf *dst, const struct os_mbuf *src,
int rc;
src_cur_om = os_mbuf_off(src, src_off, &src_cur_off);
- if (src_cur_om == NULL) {
- return OS_EINVAL;
- }
-
while (len > 0) {
+ if (src_cur_om == NULL) {
+ return OS_EINVAL;
+ }
+
chunk_sz = min(len, src_cur_om->om_len - src_cur_off);
rc = os_mbuf_append(dst, src_cur_om->om_data + src_cur_off, chunk_sz);
if (rc != 0) {