diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-08-11 08:34:34 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-08-11 08:34:34 +0200 |
commit | bf10f672ecc473547b44f98c5fda0754adf4b1b6 (patch) | |
tree | a9cb75fc6ba8c8c95f431d8efb097f1ac813337e /sys | |
parent | 09d465a9761be085b697b4ec342f5022469eb29a (diff) |
vt: fix off by one memory corruption
account for the final 0 byte in host_buf.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/src/cmd/vt/main.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/src/cmd/vt/main.c b/sys/src/cmd/vt/main.c index 739a1c422..04ad43f31 100644 --- a/sys/src/cmd/vt/main.c +++ b/sys/src/cmd/vt/main.c @@ -183,7 +183,7 @@ initialize(int argc, char **argv) break; }ARGEND; - host_buf = malloc(host_bsize); + host_buf = mallocz(host_bsize, 1); hostp = host_buf; hostlength = 0; @@ -808,8 +808,8 @@ void set_host(Event *e) { hostlength = e->n; - if(hostlength > host_bsize) { - host_bsize *= 2; + if(hostlength >= host_bsize) { + host_bsize = BSIZE*((hostlength + BSIZE)/BSIZE); host_buf = realloc(host_buf,host_bsize); } hostp = host_buf; |