ref: 19b480838af1721b833f6cd7575e994a5d55071d
parent: 7d88d76bc42e2b3f3cabde82673af4107e951797
author: Jacob Moody <[email protected]>
date: Sat May 27 19:06:42 EDT 2023
aux/kbdfs: error on invalid numerics in kbmap writes
--- a/sys/src/cmd/aux/kbdfs/kbdfs.c
+++ b/sys/src/cmd/aux/kbdfs/kbdfs.c
@@ -1252,7 +1252,7 @@
lp++;
for(e = lp; strchr("\t ", *e) == nil; e++)
;
- if(e == lp)
+ if(e == lp || *e == '\0')
goto Badarg;
*e = '\0';
for(t = 0; t < nelem(layertab); t++){
@@ -1260,10 +1260,15 @@
continue;
break;
}
- if(t == nelem(layertab))
- t = strtoul(lp, nil, 0);
- lp = e + 1;
- sc = strtoul(lp, &lp, 0);
+ if(t == nelem(layertab)){
+ t = strtoul(lp, &e, 0);
+ if(e == lp)
+ goto Badarg;
+ }
+ e++;
+ sc = strtoul(e, &lp, 0);
+ if(e == lp)
+ goto Badarg;
while(*lp == ' ' || *lp == '\t')
lp++;
if((rp = kbmapent(t, sc)) == nil)