ref: b75e549126641108880a24a4ff0b38171eb1a856
parent: 01a6de812c2fd38c9a28036300e3c2c7dc8441f5
author: Jacob Moody <[email protected]>
date: Sat May 28 13:23:41 EDT 2022
kernel: be more careful about argc for /dev/drivers writes Not crashing on 'chdev &' is important.
--- a/sys/src/9/port/devcons.c
+++ b/sys/src/9/port/devcons.c
@@ -705,18 +705,22 @@
error(Ebadarg);
if(ct->index != CMchdev)
error(Ebadarg);
- if(cb->nf < 2 || cb->nf > 3)
+ if(cb->nf == 1)
error(Ebadarg);
invert = 1;
- a = cb->f[2];
+ a = "";
switch(cb->f[1][0]){
case '&':
+ if(cb->nf != 3)
+ error(Ebadarg);
+ a = cb->f[2];
if(cb->f[1][1] == '~')
invert--;
break;
case '~':
- a = "";
+ if(cb->nf != 2)
+ error(Ebadarg);
break;
default:
error(Ebadarg);