From b0755698c1b686800c9de9e1c3d02026724d116e Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 7 Feb 2011 01:52:40 +0100 Subject: [PATCH] fix max message length handling - exclude the header --- libubus.c | 2 +- libubus.h | 2 +- ubusd.c | 2 +- ubusmsg.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libubus.c b/libubus.c index cc59006..93f8459 100644 --- 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; diff --git a/libubus.h b/libubus.h index 9f21647..cb575b0 100644 --- 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 --- 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); diff --git a/ubusmsg.h b/ubusmsg.h index 116351d..a34b341 100644 --- 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