fix max message length handling - exclude the header

This commit is contained in:
Felix Fietkau 2011-02-07 01:52:40 +01:00
parent 2429653f90
commit b0755698c1
4 changed files with 4 additions and 4 deletions

View file

@ -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;

View file

@ -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;
};

View file

@ -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);

View file

@ -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