ref: 96d32547233ded9a7560967a2b5e5a4ceb7fcde8
parent: 563cf85e63350141c763744358584ac0edfb9e2c
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Nov 2 11:31:27 EST 2025
exportfs: Handle Rstat issues Same as with lib9p, when convD2M() statbuf wont fit in Rstat response, return Rerror "message size too small". Make a constant for "message size too small".
--- a/sys/src/cmd/exportfs/exportsrv.c
+++ b/sys/src/cmd/exportfs/exportsrv.c
@@ -15,6 +15,7 @@
char Enomem[] = "No memory";
char Ereadonly[] = "File system read only";
char Enoprocs[] = "Out of processes";
+char Emsize[] = "message size too small";
ulong messagesize;
int readonly;
@@ -25,7 +26,7 @@
Fcall rhdr;
if(t->work.msize < 256){- reply(&t->work, &rhdr, "version: message size too small");
+ reply(&t->work, &rhdr, Emsize);
putsbuf(t);
return;
}
@@ -272,9 +273,16 @@
s = sizeD2M(d);
statbuf = emallocz(s);
s = convD2M(d, statbuf, s);
- free(d);
+ if(s <= BIT16SZ || s > messagesize-(BIT32SZ+BIT8SZ+BIT16SZ+BIT16SZ)){+ free(statbuf);
+ free(d);
+ reply(&t->work, &rhdr, Emsize);
+ putsbuf(t);
+ return;
+ }
rhdr.nstat = s;
rhdr.stat = statbuf;
+ free(d);
reply(&t->work, &rhdr, 0);
free(statbuf);
putsbuf(t);
--
⑨