mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
acme: validate address range, when writing to addr
Report an "address out of order" error instead of crashing, e.g. when running 9 echo -n '#3,#2' | 9p write acme/$winid/addr 9 echo -n 'dot=addr' | 9p write acme/$winid/ctl or 9 echo -n '0/yyy/,0/xxx/' | 9p write acme/$winid/addr 9 echo -n 'dot=addr' | 9p write acme/$winid/ctl with `acme/$winid/body` xxx yyy
This commit is contained in:
parent
d0d440860f
commit
5270568e3c
2 changed files with 8 additions and 1 deletions
|
@ -205,6 +205,8 @@ address(uint showerr, Text *t, Range lim, Range ar, void *a, uint q0, uint q1, i
|
|||
r.q1 = nr.q1;
|
||||
}
|
||||
*qp = q;
|
||||
if (r.q0 > r.q1)
|
||||
*evalp = FALSE;
|
||||
return r;
|
||||
case '+':
|
||||
case '-':
|
||||
|
|
|
@ -21,6 +21,7 @@ char Edel[] = "deleted window";
|
|||
char Ebadctl[] = "ill-formed control message";
|
||||
char Ebadaddr[] = "bad address syntax";
|
||||
char Eaddr[] = "address out of range";
|
||||
char Eaddrord[] = "address out of order";
|
||||
char Einuse[] = "already in use";
|
||||
char Ebadevent[] = "bad event syntax";
|
||||
extern char Eperm[];
|
||||
|
@ -493,7 +494,11 @@ xfidwrite(Xfid *x)
|
|||
break;
|
||||
}
|
||||
if(!eval){
|
||||
respond(x, &fc, Eaddr);
|
||||
if (a.q0 > a.q1) {
|
||||
respond(x, &fc, Eaddrord);
|
||||
} else {
|
||||
respond(x, &fc, Eaddr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
w->addr = a;
|
||||
|
|
Loading…
Reference in a new issue