summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBurnZeZ <devnull@localhost>2020-03-20 18:08:34 +0000
committerBurnZeZ <devnull@localhost>2020-03-20 18:08:34 +0000
commitaa5e86a8caba5ede5626d09c5cb0997530920e57 (patch)
tree1f58ea5dd8bac4a08de53e5f9ee5f1de1904a68b
parent37b86df09ff381bcc4f60802d43e57bd9bfcac73 (diff)
downloadplan9front-aa5e86a8caba5ede5626d09c5cb0997530920e57.tar.xz
kbdfs: fix kbmapread() not accounting for reads smaller than the size of the line
-rw-r--r--sys/src/cmd/aux/kbdfs/kbdfs.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/sys/src/cmd/aux/kbdfs/kbdfs.c b/sys/src/cmd/aux/kbdfs/kbdfs.c
index aa7e72050..172c91258 100644
--- a/sys/src/cmd/aux/kbdfs/kbdfs.c
+++ b/sys/src/cmd/aux/kbdfs/kbdfs.c
@@ -1091,21 +1091,22 @@ void
kbmapread(Req *req)
{
char tmp[3*12+1];
- int t, sc, off, n;
+ int t, sc, soff, off, n;
Rune *rp;
off = req->ifcall.offset/(sizeof(tmp)-1);
+ soff = req->ifcall.offset%(sizeof(tmp)-1);
t = off/Nscan;
sc = off%Nscan;
- if(rp = kbmapent(t, sc))
+ if(rp = kbmapent(t, sc)){
sprint(tmp, "%11d %11d %11d\n", t, sc, *rp);
- else
- *tmp = 0;
- n = strlen(tmp);
- if(req->ifcall.count < n)
- n = req->ifcall.count;
- req->ofcall.count = n;
- memmove(req->ofcall.data, tmp, n);
+ n = strlen(&tmp[soff]);
+ if(req->ifcall.count < n)
+ n = req->ifcall.count;
+ req->ofcall.count = n;
+ memmove(req->ofcall.data, &tmp[soff], n);
+ }else
+ req->ofcall.count = 0;
respond(req, nil);
}