ref: aaba04610a582e2f1e53571afe81913819bb5f2f
parent: 78b8f189016b29c2b1c1bf8b831dccfb95cecc3c
author: kvik <kvik@a-b.xyz>
date: Sat Dec 26 23:17:28 EST 2020
mq: clamp response to request size
--- a/src/mq.c
+++ b/src/mq.c
@@ -191,11 +191,15 @@
void
respondmessage(Req *r)
{
+ int n;
Client *c = r->fid->aux;
Write *w = c->cursor;
-
- r->ofcall.count = w->count;
- memmove(r->ofcall.data, w->data, w->count);
+
+ n = w->count;
+ if(n > r->ifcall.count)
+ n = r->ifcall.count;
+ r->ofcall.count = n;
+ memmove(r->ofcall.data, w->data, n);
respond(r, nil);
}