The push data code currently sends packets with MAX_PAYLOAD. This allows
some checks to be dropped. For example, the check if data must be send out
is just a check if the current data still can be copied to the output
buffer. But this would also mean that data with a size larger than
(MAX_PAYLOAD - sizeof(struct alfred_push_data_v0)) may trigger an empty
packet.

This is not a problem by itself because currently the data + header in
the dataset cannot be larger than
(MAX_PAYLOAD - sizeof(struct alfred_push_data_v0)).

Signed-off-by: Sven Eckelmann <[email protected]>
---
 send.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/send.c b/send.c
index 5a92132..43c10f4 100644
--- a/send.c
+++ b/send.c
@@ -83,4 +83,8 @@ int push_data(struct globals *globals, struct interface 
*interface,
                if (total_length + dataset->data.header.length + sizeof(*data) >
                    MAX_PAYLOAD - sizeof(*push)) {
+                       /* is there any data to send? */
+                       if (total_length == 0)
+                               continue;
+
                        tlv_length = total_length;
                        tlv_length += sizeof(*push) - sizeof(push->header);
-- 
2.1.4

Reply via email to