ref: 72bd25040806e6da1240ef81f7cd4a25aea897ae
parent: ff6240d98a2f496be27d0afc371b2749d16bdc35
author: Jacob Moody <moody@posixcafe.org>
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)
--
⑨