shithub: riscv

Download patch

ref: 9585e9b7f842fcd0922fe04cae5ed87e7c455728
parent: 86eb8ea6bbbf031d71cf0fa58f468cd3ddc4e7f3
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Aug 6 07:42:05 EDT 2015

kernel: limit syscallfmt user strings to 64K (as in validname)

--- a/sys/src/9/port/syscallfmt.c
+++ b/sys/src/9/port/syscallfmt.c
@@ -36,8 +36,8 @@
 static void
 fmtuserstring(Fmt* f, char* a, char* suffix)
 {
+	char *t, *e;
 	int n;
-	char *t;
 
 	if(a == nil){
 		fmtprint(f, "0/\"\"%s", suffix);
@@ -44,7 +44,10 @@
 		return;
 	}
 	validaddr((uintptr)a, 1, 0);
-	n = ((char*)vmemchr(a, 0, ~0) - a) + 1;
+	n = 1<<16;
+	e = vmemchr(a, 0, n);
+	if(e != nil)
+		n = e - a;
 	t = smalloc(n+1);
 	memmove(t, a, n);
 	t[n] = 0;