git: 9front

Download patch

ref: ecc8a0e60936ce01e469ae37d3689c228c297136
parent: fdf21a19a5c6c75bcd66ee5ece4d4fd99b910105
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Feb 28 11:48:42 EST 2020

devproc: make sure writewatchpt() doesnt overflow the watchpoint array

the user buffer could be changed while we parse it resulting
in a different number of watchpoints than initially calculated.
so add a check to the parse loop so we wont overflow the
watchpoint array.

--- a/sys/src/9/port/devproc.c
+++ b/sys/src/9/port/devproc.c
@@ -812,7 +812,7 @@
 	}
 	if(nwp0 > 0)
 		memmove(wp, pr->watchpt, sizeof(Watchpt) * nwp0);
-	for(wq = wp + nwp0;;){
+	for(wq = wp + nwp0; wq < wp + nwp0+nwp;){
 		q = memchr(p, '\n', e - p);
 		if(q == nil)
 			break;
--