fix max message length handling - exclude the header
authorFelix Fietkau <nbd@openwrt.org>
Mon, 7 Feb 2011 00:52:40 +0000 (01:52 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 7 Feb 2011 00:52:40 +0000 (01:52 +0100)
libubus.c
libubus.h
ubusd.c
ubusmsg.h

index cc59006..93f8459 100644 (file)
--- a/libubus.c
+++ b/libubus.c
@@ -153,7 +153,7 @@ static bool ubus_validate_hdr(struct ubus_msghdr *hdr)
        if (blob_raw_len(hdr->data) < sizeof(*hdr->data))
                return false;
 
-       if (blob_raw_len(hdr->data) + sizeof(*hdr) > UBUS_MAX_MSGLEN)
+       if (blob_pad_len(hdr->data) > UBUS_MAX_MSGLEN)
                return false;
 
        return true;
index 9f21647..cb575b0 100644 (file)
--- a/libubus.h
+++ b/libubus.h
@@ -97,7 +97,7 @@ struct ubus_context {
 
        struct {
                struct ubus_msghdr hdr;
-               char data[UBUS_MAX_MSGLEN - sizeof(struct ubus_msghdr)];
+               char data[UBUS_MAX_MSGLEN];
        } msgbuf;
 };
 
diff --git a/ubusd.c b/ubusd.c
index aa74550..14eb537 100644 (file)
--- a/ubusd.c
+++ b/ubusd.c
@@ -206,7 +206,7 @@ retry:
                if (cl->pending_msg_offset < sizeof(cl->hdrbuf))
                        goto out;
 
-               if (blob_len(&cl->hdrbuf.data) + sizeof(cl->hdrbuf) > UBUS_MAX_MSGLEN)
+               if (blob_pad_len(&cl->hdrbuf.data) > UBUS_MAX_MSGLEN)
                        goto disconnect;
 
                cl->pending_msg = ubus_msg_new(NULL, blob_raw_len(&cl->hdrbuf.data), false);
index 116351d..a34b341 100644 (file)
--- a/ubusmsg.h
+++ b/ubusmsg.h
@@ -6,7 +6,7 @@
 
 #define __packetdata __attribute__((packed)) __attribute__((__aligned__(4)))
 
-#define UBUS_MAX_MSGLEN        65535
+#define UBUS_MAX_MSGLEN        65536
 
 #define UBUS_SYSTEM_OBJECT_EVENT       1
 #define UBUS_SYSTEM_OBJECT_MAX         1024