summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rio/xfid.c
diff options
context:
space:
mode:
authorAlex Musolino <alex@musolino.id.au>2019-11-19 12:38:13 +1030
committerAlex Musolino <alex@musolino.id.au>2019-11-19 12:38:13 +1030
commit4d4107b38547c7f9f135cc22d3a29fcbad4a8c34 (patch)
tree190cd80be55d2de59fc66bc4c738c479c0f81b81 /sys/src/cmd/rio/xfid.c
parentf32148b290be11d46d3c1e419285f46c7fbb308b (diff)
rio: fix bug causing short reads of wctl files
Previously, reads of wctl files would return one byte less than requested as the returned string must be null terminated. Now we pass the actual size of the allocated buffer to the handler, which is large enough to accommodate a trailing partial rune and terminating null byte.
Diffstat (limited to 'sys/src/cmd/rio/xfid.c')
-rw-r--r--sys/src/cmd/rio/xfid.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/src/cmd/rio/xfid.c b/sys/src/cmd/rio/xfid.c
index 3985bea00..b8e4be84a 100644
--- a/sys/src/cmd/rio/xfid.c
+++ b/sys/src/cmd/rio/xfid.c
@@ -670,9 +670,9 @@ xfidread(Xfid *x)
}
c1 = crm.c1;
c2 = crm.c2;
- t = emalloc(cnt+UTFmax+1); /* room to unpack partial rune plus */
+ pair.ns = cnt+UTFmax+1; /* room for partial rune and null byte */
+ t = emalloc(pair.ns);
pair.s = t;
- pair.ns = cnt;
send(c1, &pair);
recv(c2, &pair);
fc.data = pair.s;