From 072baa98249367d91c1be89fd4438f04315bef18 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Mon, 17 Nov 2008 20:50:15 -0300 Subject: [PATCH] obexd: Fixes the case when serving folder listings bigger than MTU size --- obexd/src/obex.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/obexd/src/obex.c b/obexd/src/obex.c index 2c1b41ce9..3a0f3c2d1 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -456,6 +456,7 @@ static gint obex_write_stream(struct obex_session *os, { obex_headerdata_t hd; gint32 len; + guint8 *ptr; debug("obex_write_stream: name=%s type=%s tx_mtu=%d fd=%d", os->name ? os->name : "", os->type ? os->type : "", @@ -468,7 +469,8 @@ static gint obex_write_stream(struct obex_session *os, if (os->buf == NULL) return -EIO; - len = os->size - os->offset; + len = MIN(os->size - os->offset, os->tx_mtu); + ptr = os->buf + os->offset; goto add_header; } @@ -481,7 +483,12 @@ static gint obex_write_stream(struct obex_session *os, return -err; } + ptr = os->buf; + add_header: + + hd.bs = ptr; + if (len == 0) { OBEX_ObjectAddHeader(obex, obj, OBEX_HDR_BODY, hd, 0, OBEX_FL_STREAM_DATAEND); @@ -490,7 +497,6 @@ add_header: return len; } - hd.bs = os->buf; os->offset += len; OBEX_ObjectAddHeader(obex, obj, OBEX_HDR_BODY, hd, len, -- 2.47.3