git: drawterm

Download patch

ref: c78114eb74f78c4756cee7938217fdd33122f45b
parent: 48d53278a8273bb39ca295e8f163563ab04b3530
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Nov 11 06:45:55 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/exportfs/exportsrv.c
+++ b/exportfs/exportsrv.c
@@ -14,6 +14,7 @@
 char Enopsmt[] = "Out of pseudo mount points";
 char Enomem[] = "No memory";
 char Ereadonly[] = "File system read only";
+char Emsize[] = "message size too small";
 
 int readonly;
 
@@ -23,7 +24,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;
 	}
@@ -237,9 +238,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);
--