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.
This commit is contained in:
cinap_lenrek 2020-02-28 16:48:42 +01:00
parent adb36de077
commit 17a92f3995

View file

@ -812,7 +812,7 @@ writewatchpt(Proc *pr, char *buf, int nbuf, uvlong offset)
}
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;