kbdfs: fix kbmapread() not accounting for reads smaller than the size of the line
This commit is contained in:
parent
37b86df09f
commit
aa5e86a8ca
|
@ -1091,21 +1091,22 @@ void
|
||||||
kbmapread(Req *req)
|
kbmapread(Req *req)
|
||||||
{
|
{
|
||||||
char tmp[3*12+1];
|
char tmp[3*12+1];
|
||||||
int t, sc, off, n;
|
int t, sc, soff, off, n;
|
||||||
Rune *rp;
|
Rune *rp;
|
||||||
|
|
||||||
off = req->ifcall.offset/(sizeof(tmp)-1);
|
off = req->ifcall.offset/(sizeof(tmp)-1);
|
||||||
|
soff = req->ifcall.offset%(sizeof(tmp)-1);
|
||||||
t = off/Nscan;
|
t = off/Nscan;
|
||||||
sc = off%Nscan;
|
sc = off%Nscan;
|
||||||
if(rp = kbmapent(t, sc))
|
if(rp = kbmapent(t, sc)){
|
||||||
sprint(tmp, "%11d %11d %11d\n", t, sc, *rp);
|
sprint(tmp, "%11d %11d %11d\n", t, sc, *rp);
|
||||||
else
|
n = strlen(&tmp[soff]);
|
||||||
*tmp = 0;
|
|
||||||
n = strlen(tmp);
|
|
||||||
if(req->ifcall.count < n)
|
if(req->ifcall.count < n)
|
||||||
n = req->ifcall.count;
|
n = req->ifcall.count;
|
||||||
req->ofcall.count = n;
|
req->ofcall.count = n;
|
||||||
memmove(req->ofcall.data, tmp, n);
|
memmove(req->ofcall.data, &tmp[soff], n);
|
||||||
|
}else
|
||||||
|
req->ofcall.count = 0;
|
||||||
respond(req, nil);
|
respond(req, nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue